The configuration of many Linux features depends on settings that you store in text files. You must, therefore, know how to edit text files to set up and maintain a Linux system. Another form of text processing involves typesetting and formatting text documents. Linux includes groff for this purpose. Nowadays, you’re likely to use a PC to prepare formatted documents, but you still need to prepare one kind of formatted document: the man pages that provide online help for any software that you write. Accordingly, this chapter shows you how to use several text editors. It also shows you how to prepare man pages by using groff.
By reading this chapter, you learned the following:
Linux includes a variety of text editors. Learning the ed and vi editors is important, because all UNIX systems come with these editors. Although the ed editor may seem cryptic, you may need to use it to edit files if no other editor is available.
The ed editor works on a text file one line at a time (which is why it’s called a line editor). Each command takes the form of a range of lines, followed by a one-character command that applies to that range of lines.
The vi editor is a full-screen editor that enables you to view a file several lines at a time. The vi editor has three modes: visual-command mode, colon-command mode, and text-input mode.
In vi’s text-input mode, you can enter text. To change to text-input mode, press i, a, or A. To return to command mode, press Esc.
In vi’s colon-command mode, you enter a colon (:) followed by a command that uses the same syntax as ed commands.
GNU Emacs is more than just an editor—it’s also an environment from which you can perform most routine tasks.
As an editor, GNU Emacs doesn’t have any modes; whatever you type goes into the file. Commands begin with a control character (such as Ctrl-x) or Esc.
To view the online tutorial, type C-h t in GNU Emacs.
The groff utility is useful for formatting documents. groff provides the functionality of the standard UNIX nroff and troff utilities. You must use groff to prepare man pages.
The best way to learn to prepare a man page is to study an existing man page and mimic its style in your own man page. This chapter provided an example of how you can prepare a typical man page.
DocBook is a markup language for structured document layout. DocBook is defined using SGML or XML document type definitions (DTDs). Red Hat Linux comes with DocBook DTDs and stylesheets. This chapter showed you how to get started with DocBook.