vi format command
Bill Petro
rock%warp at Sun.COM
Tue Sep 12 10:30:49 AEST 1989
sct at alpha.lanl.gov (Stephen Tenbrink) writes:
>Is there a technique for reformatting a paragraph when using vi? Sometimes
>when one has deleted and added text to a paragraph the lines no longer end
>near the right side of the screen. Some editors such as EDT have a
>technique of selecting the whole paragraph and then entering a command to
>reformat the whole paragraph. The word wrap margin is used to set the
>right hand margin.
>I'm sure there is a way to do this easier than inserting 'returns' and
>using the 'J' command. Does anyone have an answer?
" at top of paragraph, format this paragraph
!} fmt -c
" for the whole file, format all paragraphs
!G fmt -c
"from here to the end of the file, format all paragraphs
!$ fmt -c
" from anwhere in the paragraph, format this paragraph
{!}fmt -c
Here's how I map them in my .exrc file:
map @f !} fmt -c^M
map @F !G fmt -c^M
map ^Xf !$ fmt -c^M
map ^XF {!}fmt -c^M}^M
P.S. the -c option to fmt is for "crown" formatting, preserving the
indention of the first 2 lines within a paragraph. You can leave it
off.
Bill Petro {decwrl,hplabs,ucbvax}!sun!Eng!rock
"UNIX for the sake of the kingdom of heaven" Matthew 19:12
More information about the Comp.unix.questions
mailing list