Feb. 2, 2011, 10:16 p.m.
posted by juff
The four kinds of UNIX programs that handle text are
Desktop publishing programs
Before describing the most commonly used text editors in gory detail, we thought that you would want to know the differences among these four kinds of programs, in case you plan to impersonate a geek at the next meeting of your local UNIX users’ group.
A text editor enables you to
Create a file full of text
Edit the text
You can print a file by using the lp or lpr programs, as described in Chapter 9, although text editors can’t do boldface, headers or footers, italics, or all that other fancy stuff you need in order to produce modern, overformatted, professional-quality memos.
You may want to use a text editor to write letters and reports. You certainly will use one to send electronic mail, as described in Chapter 17.
The most commonly used text editors in the land of UNIX are vi, emacs, and pico. We have strong opinions about these editors, which becomes abundantly clear in the later sections in this chapter, where we tell you how to use each of them.
Text formatters are programs that read text files and create nice-looking formatted output. You use a text editor to make a text file that contains special little commands only the formatter understands; the .IT command, for example, makes something italic. When you run the text formatter, it reads the text file, reads the special little commands, and creates a formatted file you can then print. You use lp or lpr to print the output of the text formatter.
The most common UNIX text formatter is TeX, pronounced "teccccch" (like yeccccch), an arcane language popular among mathematicians and physicists because of its capability to format large, complex equations, and because it produces more aesthetically pleasing results than any of its competitors. A companion program, LaTeX, is designed to make TeX easier to use (relatively speaking, of course). (See the nearby sidebar, "Howdy, TeX!" for more info about TeX and LaTeX and where to get them.)
Another common text formatter is troff. Some people use nroff (an older version of troff), or groff, a newer GNU version of the program. With luck, you never have to use any of them. If your luck has run out, you may want to check out the section about troff, nroff, and groff in Chapter 9.
Word processors combine the capabilities of text editors and text formatters. Most word processors are (or try to be) WYSIWYG (an acronym for What You See Is What You Get), which enables you to see on-screen how the document (that’s what they call their files) will look when you print them.
Several surprisingly good, free word processors are available for UNIX. KWord, which comes with the KDE desktop package, is a simple but quite usable word processor. AbiWord is quite similar to Microsoft Word, and OpenOffice.org contains equivalents to most of the Microsoft Office. When writing this original version of this book in 1993, we used troff, but for the current edition we used OpenOffice.org Writer, which produced files that, to our editor’s relief, work fine in Microsoft Word.
Most UNIX users think that word processors are for wimps (what you see is all you’ve got) because they like the unintelligible and unmemorable commands used by text formatters and prefer to imagine what their text will look like when it is printed rather than be able to see it on-screen. Text formatters can do more complex things than word processors can, such as format complicated mathematical expressions, lay out multi-page tables, and neatly organize sections and headers of huge, book-length documents. But that’s probably not your problem.
A desktop publishing (DTP) program resembles a fancy word processor. It can do everything a word processor can, plus things you need only if you are printing a book, newsletter, or something else that looks fancy. DTPs have facilities for creating tables of contents and indexes, maintaining cross- references — you name it. For writing an occasional memo, a desktop publishing program is definitely overkill.
The most popular desktop publishing program for UNIX is Adobe FrameMaker (available for PCs and Macintoshes also).
TeX and some versions of troff are available for free, which explains why they remain so popular (big surprise, eh?). All desktop publishers are commercial products that cost extra. Lots extra.
The rest of this chapter explains how to use each of the Big Three text editors (vi, emacs, and pico), along with some words about how to use the prehistoric but not yet extinct ed (who, as you will see, is not your friend). Even if you use a word processor or desktop publishing program, you may need to use a text editor to do some things, such as these tasks:
Write electronic mail (see Chapter 17).
Create or edit text files called shell scripts, which enable you to create your own UNIX commands (see Chapter 12).
Create or edit special text files that control the way your UNIX setup works (see Chapter 7).
Write C programs (just kidding!).