Formatting Posts With VI

From: Alan Connor (zzzzzz_at_xxx.yyy)
Date: 09/12/04


Date: Sun, 12 Sep 2004 00:41:13 GMT

I just stumbled across this little 'trick' and thought it was worth
passing on.

What the following allows you to do is to simply hit "v" while you are in
command mode, and it will re-format the paragraph your cursor is currently
on, to a maximum line length of 75 characters, splitting and filling as
it works. (The -c option tells it to leave an indented first line alone.)

(You can change the line length; see man fmt.)

In your ~/.exrc, type the following:

map v {0!}fmt -c^V^V^V^M

(For the newbies: "^V" means hold down Ctrl and press v)

What you will see in vi is:

map v {0!}fmt -c^V^M

With just cat or less you'll see:

map v {0!}fmt -c

---------------------------------------

This is *really* handy if you are writing anything and have to go back
and add or delete words in a sentence near the beginning of a long par-
agraph. Do the editing, go back to command mode, and hit "v" and 99 times
times out of a 100 the paragraph is okay again. If it isn't perfect,
only a few keystrokes will fix the problem, compared to the tedium of
doing the whole thing manually.

AC



Relevant Pages

  • Formatting Posts With VI
    ... map v fmt -c^V^M ... Do the editing, go back to command mode, and hit "v" and 99 times ... times out of a 100 the paragraph is okay again. ...
    (comp.os.linux.misc)
  • Formatting Posts With VI
    ... map v fmt -c^V^M ... Do the editing, go back to command mode, and hit "v" and 99 times ... times out of a 100 the paragraph is okay again. ...
    (alt.os.linux)
  • Re: vim wrapping [Was: Re: mutt is the bomb! (LDAP addressbook integration)]
    ... Put your cursor in the paragraph, in command mode, hit ...
    (Debian-User)
  • RE: section break/insert file
    ... any paragraph marks after "Remove Form". ... then hit the Right arrow on the keyboard. ... Range object to see if the new range is what it should be. ...
    (microsoft.public.word.vba.general)
  • Re: BFBC2 Update
    ... picked up some bad squad habits. ... Nice map... ... The beauty of it from my point of view was all the enemy soldiers kept targeting the tank alone, leaving me free to pick them off one by one as they lined up their bazookas and tried holding their aim long enough for a mortar strike. ... One shot kills from any range if you can hit people, ...
    (uk.games.video.misc)