how to reformat a paragraph of sgml source to 80 column width for easier editing? emacs kung fu comes to help
I have not been using emacs for 10 years, but now that I was trying to reformat some documentation source to conform to an 80 character per line style, I remembered emacs’s neat ‘esc-q’ reformat feature.
Now since that just reformats everything, I was wondering how to do that just for a selected paragraph. With the help of some gurus on #emacs I quickly got the recipe together:
1. set word-wrap column to 80 (default is 70):
ctrl-u 80 esc-x set-fill-column
2. select the region you want to reformat:
move to beginning, ctrl-space, go to the end and perform next step
3. narrow down to selected region:
ctrl-x n n
(The first time you do that you have to confirm with y)
5. undo narrow down of region to see full document:
ctrl-x n w
Lather, rinse, repeat, … DONE.
Back to vi🙂