In Emacs, I have a paragraph of text, which is already properly wrapped at, say 79th column on each row, then you edit it, adding some text on some of the rows, how to reformat the edited paragraph so the line break characters are automatically removed and inserted in correct places such that the resultant paragraph are again line breaking at 79th column for each row, or whatever is proper for the current mode, say python-mode?
Asked
Active
Viewed 1.3k times
22
qazwsx
- 9,311
1 Answers
33
You should use the fill-paragraph command, normally bound to meta-q. (You can use ESC q if your keyboard doesn't have a meta key.) Paragraph filling only makes sense in free text modes or within comments in programming language modes. Programming language modes are usually setup around the TAB key to properly indent lines; line breaks are inserted manually.
To set the column at which lines of text are broken, use the set-fill-column command. Place the cursor at the column you want the line to end, and type control-u control-x f and that column will become the fill column for the current buffer. Use fill-paragraph to refill the paragraph with the new fill column.
Kyle Jones
- 6,364