30.37 Neatening LinesHave you made edits that left some of your lines too short or long? The fmt ( 35.2 ) utility can clean that up. Here's an example. Let's say you're editing a file (email message, whatever) in vi and the lines aren't even. They look like this:
This file is a mess with some short lines and some lines that are too long - like this one, which goes on and on for quite a while and etc. Let's see what 'fmt' does with it. You put your cursor on the first line and type (in command mode):
which means " filter ( 30.22 ) 5 lines through fmt ." Then the lines will look like this:
This file is a mess with some short lines and some lines that are too long - like this one, which goes on and on for quite a while and etc. Let's see what 'fmt' does with it. This is handiest for formatting paragraphs. Put your cursor on the first line of the paragraph and type (in command mode):
If you don't have any text in your file that needs to be kept as is, you can neaten the whole file at once by typing:
There are a few different versions of fmt , some fancier than others. Most of the articles in the chapter about editing-related tools can be handy too. For example, recomment ( 35.4 ) reformats program comment blocks. cut ( 35.14 ) can remove columns, fields, or shorten lines; tr ( 35.11 ) can do other transformations. To neaten columns, try filtering through with the setup in article 35.22 . In general, if the utility will read its standard input and write converted text to its standard output, you can use the utility as a vi filter. - |
|