ss@chip.UUCP (Steve Schossow) (08/25/89)
I'm writing this with vi. I know how to set my wrapmargin to get the paragraphs to break properly when I'm entering text. But what if I re-arrange the text after entering it. How do I get vi to reformat the result? Does someone have a macro that will do what I need? Please no flames about why am I using vi, how I should be using emacs, etc.. E-mail is fine. I can be reached as 'chip!ss@nosc.mil' I believe.
jdpeek@RODAN.ACS.SYR.EDU ("Jerry Peek") (08/27/89)
In article <263@chip.UUCP> ss@chip.UUCP (Steve Schossow) writes: > I'm writing this with vi. I know how to set my wrapmargin to get the > paragraphs to break properly when I'm entering text. But what if I > re-arrange the text after entering it. How do I get vi to reformat the > result? Does someone have a macro that will do what I need? "vi" lets you feed a chunk of text from your buffer to an external command, then read the result back to replace the original text. Do this with vi's ! (exclamation point) command. The format is: !<where-to><filter_command> where <where-to> is a "vi" where-to command like "}", "23G", "L", etc. and <filter_command> is a utility like "fmt" (if you have it). For example, to clean up the current paragraph, put your cursor on the first line and type: !}fmt (then press RETURN) to do this paragraph and two more: !3}fmt To clean up the rest of the file, use: !Gfmt A count of lines works, too. For instance, to format this line and three more: 4!!fmt If your system doesn't have "fmt", there are public-domain ones around. Once I wrote a shell script that used "nroff," plus a few nroff commands, to do centering of lines. Any program that reads stdin and writes stdout will work. My favorite is a shell script like "fmt" called "recomment". It reformats comments in program source by figuring out what the comment character(s) are, neatening the lines and putting back the comment characters. --Jerry Peek; Syracuse University Academic Computing Services; Syracuse, NY jdpeek@rodan.acs.syr.edu///JDPEEK@SUVM.BITNET///GEnie: J.PEEK1 +1 315 443-3995