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)

4. reformat:
esc-q

5. undo narrow down of region to see full document:
ctrl-x n w

Lather, rinse, repeat, … DONE.

Back to vi :)

About these ads

~ by MrMichaelWill on March 4, 2009.

One Response to “how to reformat a paragraph of sgml source to 80 column width for easier editing? emacs kung fu comes to help”

  1. Thanks, this showed up in the first results in googlesearch and it helped me do the trick.


    Noe
    C-x C-s

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: