Книга: Fedora™ Unleashed, 2008 edition

Working with emacs

Working with emacs

Richard M. Stallman's GNU emacs editor, like vi, is included with Linux and nearly every other Linux distribution. Unlike other UNIX and Linux text editors, emacs is much more than a simple text editor — it is an editing environment and can be used to compile and build programs, act as an electronic diary, appointment book and calendar, compose and send electronic mail, read Usenet news, and even play games. The reason for this capability is that emacs contains a built-in language interpreter that uses the Elisp(emacs LISP) programming language.

The GNU version of this editor requires more than 30MB of hard drive space. However, there are versions with fewer resource requirements, and at least one other text editor included with Linux, named joe, can be used as an emacs clone (albeit with fewer features).

You can start an emacs editing session like this:

$ emacs file.txt

TIP

If you start emacs when using X11, the editor launches in its own floating window. To force emacs to display inside a terminal window rather than its own window (which can be useful if the window is a login at a remote computer), use the -nw command-line option like this:emacs -nw file.txt.

The emacs editor uses an extensive set of keystroke and named commands, but you can work with it by using a basic command subset. Many of these basic commands require you to hold down the Ctrl key, or to first press a meta key (generally mapped to the Alt key). The basic commands are listed in Table 4.2.

TABLE 4.2 Emacs Editing Commands

Action Command
Abort Ctrl+G
Cursor left Ctrl+B
Cursor down Ctrl+N
Cursor right Ctrl+F
Cursor up Ctrl+P
Delete character Ctrl+D
Delete line Ctrl+K
Go to start of line Ctrl+A
Go to end of line Ctrl+E
Help Ctrl+H
Quit Ctrl+X, Ctrl+C
Save As Ctrl+X, Ctrl+W
Save file Ctrl+X, Ctrl+S
Search backward Ctrl+R
Search forward Ctrl+S
Start tutorial Ctrl+H, T
Undo Ctrl+X, U

TIP

One of the best reasons to learn how to use emacs is that you can use nearly all the same keystrokes to edit commands on the bash shell command line. Another reason is that like vi, emacs is universally available on nearly every UNIX and Linux system, including Apple's Mac OS X.

Оглавление книги

Оглавление статьи/книги

Генерация: 0.094. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз