35.2 Neatening Text with fmt
One of the problems with fold (43.8 ) is that it breaks text at an arbitrary column position - even if that position happens to be in the middle of a word. It's a pretty primitive utility, designed to keep long lines from printing off the edge of a line printer page, and not much more.
fmt can do a better job because it thinks in terms of language constructs like paragraphs. fmt wraps lines continuously, rather than just folding the long ones. It assumes that paragraphs end at blank lines.
You can use fmt for things like neatening lines of a mail message or a file that you're editing with vi (30.37 ) . (Emacs has its own built-in line-neatener.) It's also great for shell programming and almost any place you have lines that are too long or too short for your screen.
There are a few different versions of fmt , some fancier than others. In general, the program assumes that:
Alternatively, you can make your own (35.3 ) simple (and a little slower) version with sed and nroff . If you want to get fancy (and use some nroff and/or tbl coding), this will let you do automatically formatted text tables, bulleted lists, and much more.