kz08+@andrew.cmu.edu (Ken Zuroski) (03/22/90)
Hello, everyone: I'm a gnu-emacs user, but I'd thought I'd try something different. And so I taught myself VI. It's pretty neat! But one thing I miss: the equivalent of an emacs "fill-paragraph" command, which I use quite frequently when I'm doing a lot of editing and messing my margins up. I don't see any mention of a VI "fill-paragraph" in the manual; any solution other than to pipe the doc through nroff (which I won't do, 'cause it's too time consuming)? Is there a way to build a macro to do this? Many thanks! --ken zuroski kz08@andrew.cmu.edu
kz08+@andrew.cmu.edu (Ken Zuroski) (03/22/90)
A lot of people have responded to my earlier post; many thanks. The most common solution to my problem was !}fmt. But I can't get this to work! I've been trying all night. Whenever I try this I get the error message "}fmt: command not found" or something like that. What am I doing wrong? I've looked in all the manuals. It knows where to find fmt, for if I do "!fmt" the screen locks up until I do a control-d (and exit fmt). For some reason it's hanging up on the "}". But if I type that character in edit mode, it'll cause me to skip ahead a paragraph, just like it's supposed to. I tried this on two machines, one running BSD 4.xx and the other running DYNIX (uh, maybe ULTRIX; whatever a Sequent machine would run). What gives? Please forgive this novice VI user for such a simplistic question. --ken zuroski kz08@andrew.cmu.edu
steinbac@hpl-opus.HP.COM (Gunter Steinbach) (03/22/90)
Try !}adjust or !}format I use adjust on HP-UX, it has selectable right margin (-m<margin>) and right-justify (-j). Is quick, too, you don't leave vi. Guenter Steinbach gunter_steinbach@hplabs.hp.com
wyle@inf.ethz.ch (Mitchell Wyle) (03/23/90)
In article <Ma1xBQq00W06I2gFpr@andrew.cmu.edu> kz08+@andrew.cmu.edu (Ken Zuroski) writes: >I taught myself VI. It's pretty neat! But one thing I miss: the equivalent >of an emacs "fill-paragraph" command, which I use quite frequently when I'm >doing a lot of editing and messing my margins up. I don't see any mention >of a VI "fill-paragraph" in the manual; any solution other than to pipe the >doc through nroff (which I won't do, 'cause it's too time consuming)? Is >there a way to build a macro to do this? There is the macro: map @ {j!}fmt^V^M}be which forks a shell and uses Unix fmt(1) to fill your paragraph. As you say, it is slow to fork a shell. Then there is this bizarre thingy: map F jf k0J72^V|EBr map @ {jFFFFFFFFFFFFFFFFFFFFF which depends on the "f k" to fail at the end of a paragraph (blank line). It is a bit faster but I prefer the former (fork a subshell) which is more robust. They keep upgrading our hardware, and the vendors keep coming up with more clever software. On a sparcstation-1 Sun-OS 4.0.3, if you !}fmt in vi frequently, it gets faster and faster until it is just as fast as the second, all-vi macro above. The OS seems to second-guess what you're going to do...
steveha@microsoft.UUCP (Steve HASTINGS) (03/23/90)
The traditional way to fill paragraphs is to pipe the paragraph through the fmt program. The pipe command in vi works like the delete command: you type the command to invoke it, and then you specify what it should work on. Just as "d}" will delete the rest of the current paragraph, "!}" will pipe the rest of the paragraph through a command. You will be prompted for the command to use; type "fmt" and watch your paragraph fill. Note that the "}" command wants nroff/troff commands to figure out where the paragraph ends, but a blank line will also indicate the end of a paragraph so you can still use this on simple text files. If you don't have fmt, you can write a simple program to do the same thing. It should read the standard input and write the standard output. The pipe feature of vi is one of my favorites. I often use "!Gsort" to order a list in a file.