-->
Page 211
Hour
Page 212
Page 213
This hour provides you with an overview of some word processing, or text editing, tools for Linux. There's not enough time to cover all of the 100 or more Linux text editors, but this hour provides you with highlights of the features of the tools you'll find on your CD-ROM. It also shows you the basics of using these editors to get you started.
Text editors are used by many different types of people. Casual users, writers, programmers, and system administrators will all use a text editor at one time or another in Linux. You'll definitely need to know how to change text files to configure Linux to work the way you want. What follows is an introduction to different word processors, text editors, and text tools you can use during your Linux sessions.
Although how you use a computer dictates what type of software is important
Page 214
and should be installed, most people agree that more than half our time when using a computer is spent using a text editor or word processor. This will change, of course, as computer software interfaces evolve and network communication becomes more integrated into our work environment, but in general, if you're using Linux on your computer at home you're probably going to be word processing or editing files a lot of the time.
The tools in this hour are interactive programs that allow you to enter text, move a cursor, or drop a menu. These programs and related files vary in size from nearly 20 megabytes to less than 200,000 characters. However, there are more than two dozen text tools, including line editors such as the ed or ex commands, for Linux, that while not interactive, enable you to change, manipulate, or rearrange text.
What do you call a text editor that edits text, reads Usenet news, acts as a personal calendar and diary, sends electronic mail, is a programming language interpreter, plays games, is a Linux shell, and more? Why, emacs, of course!
emacs, which stands for editing macros, was originally developed by Richard Stallman, who founded the Free Software Foundation, or FSF. The emacs editor is distributed by the FSF as part of the GNU, or GNU's Not UNIX project. Without a doubt, emacs is the most widely available and fully featured free editor, and runs on more computer systems than any other text editor.
There isn't enough time in this hour (or this book!) to cover all the features of this program. Look at Table 14.1 to find most of the keyboard commands you can use to get started.
Table 14.1. Basic emacs commands and keystroke combinations.
Action | Key Combination |
C-b=hold down Ctrl key, press b | |
M-v=hold down Alt key, press v | |
Cursor backward | C-b |
Cursor forward | C-f |
Cursor up | C-p |
Cursor down | C-n |
Go to beginning of line | C-a |
Go to end of line | C-e |
Page down | C-v |
Page 215
Action | Key Combination |
Page up | M-v |
Go to end of file | M-> |
Go to beginning of file | M-< |
Delete character | C-d |
Delete word | M-d |
Delete line | C-k |
Undo | C-_ |
Open File | C-x C-f |
Save File | C-x C-s |
Save As | C-x C-w |
Help | C-h |
Tutorial | C-h t |
Quit | C-x C-c |
emacs has 22 different command-line options, but is easy to start. To run emacs and open a text file for editing, just specify the file's name on the command line. For example,
# emacs myfile.txt
This loads the editor and opens your file. If you just specify emacs on the command line by itself, the program starts, displays an opening screen, and clears when you touch the keyboard. Starting the emacs tutorial is highly recommended if you're a beginner. Hold down the Ctrl key and press the h key. You'll see a prompt on the emacs command line at the bottom of the screen. Press the t key, and then press Enter to start the tutorial.
If you enter this command at the shell prompt of an X11 terminal window, the X11 version of emacs with mouse and menu support automatically starts (see Figure 14.1). But what if you want to run the console, or non-X11 version of emacs instead? In this case, use a different name for emacs, emacs-nox, or use the -nw, or no-window command-line option:
# emacs-nox myfile.txt # emacs -nw myfile.txt
Both commands run emacs in your X11 terminal window, although you'll still see a menu bar across the top of the terminal screen. emacs also obeys most X11 Toolkit options, such as geometry settings. Some of the X11 options you may find helpful include the following:
Page 216
Use these options, and others, to customize how emacs looks when started in X11:
# emacs -geometry 80x24 -fg black -bg white blue -cr red
This starts emacs in a window 80 characters wide by 24 lines high. The text is black, with a white background. The cursor is red, and the mouse cursor is blue. emacs also has 13 different X resource settings you can configure and enter into your .Xresources file in your home directory. You also can save editor defaults (such as word wrapping, or fill-mode on) in a file called .emacs in your home directory. See the emacs manual page for details.
The emacs program for Red Hat Linux comes in four different packages containing various
Figure 14.1.
The emacs editor
features split windows,
built-in help, a tutorial,
and other tools to help
you be more productive.
files and utilities. If you install everything, emacs requires more than 35 megabytes of disk space. You can, however, save 15 megabytes if you don't install the Emacs-d package, which is the source for emacs functions, modes, and utilities. If you don't use the X Window system, you can save another 2.5 megabytes by not installing the Emacs-X11 package.
You'll find documentation for emacs under the /usr/doc, /usr/share/emacs/20.2/etc, and /usr/info directory. You also can read the emacs manual page for an overview.