Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!apple!sun-barr!newstop!sun!warp!rock From: rock%warp@Sun.COM (Bill Petro) Newsgroups: comp.unix.questions Subject: Re: vi format command Keywords: paragraph vi editor Message-ID: <124483@sun.Eng.Sun.COM> Date: 12 Sep 89 00:30:49 GMT References: <964@alpha.lanl.gov> Sender: news@sun.Eng.Sun.COM Lines: 38 sct@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