Linux in a NutshellLinux in a NutshellSearch this book

Chapter 10. The Emacs Editor

Contents:

Emacs Concepts
Typical Problems
Notes on the Tables
Summary of Commands by Group
Summary of Commands by Key
Summary of Commands by Name

The Emacs editor is found on many Unix systems, including Linux, because it is a popular alternative to vi. Many versions are available. This book documents GNU Emacs, which is available from the Free Software Foundation in Cambridge, MA. For more information, see the O'Reilly book Learning GNU Emacs.

Emacs is much more than "just an editor"—in fact, it provides a fully integrated user environment. From within Emacs you can issue individual shell commands, or open a window where you can work in the shell, read and send mail, read news, access the Internet, write and test programs, and maintain a calendar. To fully describe Emacs would require more space than we have available. In this chapter, therefore, we focus on the editing capabilities of Emacs.

To start an Emacs editing session, type:

emacs

You can also specify one or more files for Emacs to open when it starts:

emacs files

10.1. Emacs Concepts

This section describes some Emacs terminology that may be unfamiliar if you haven't used Emacs before.

10.1.1. Modes

One of the features that makes Emacs popular is its editing modes. The modes set up an environment designed for the type of editing you are doing, with features like having appropriate key bindings available, and automatically indenting according to standard conventions for that type of document. There are two types of modes, major and minor. The major modes include modes for various programming languages like C or Perl, for text processing (e.g., SGML or even straight text), and many more. One particularly useful major mode is Dired (Directory Editor), which has commands that let you manage directories. Minor modes set or unset features that are independent of the major mode, such as auto-fill (which controls word wrapping), insert versus overwrite, and auto-save. For a full discussion of modes, see Learning GNU Emacs or the Emacs Info documentation system (C-h i).

10.1.2. Buffer and Window

When you open a file in Emacs, the file is put into a buffer so you can edit it. If you open another file, that file goes into another buffer. The view of the buffer contents that you have at any point in time is called a window. For a small file, the window might show the entire file; for a large file, it shows only a portion of a file. Emacs allows multiple windows to be open at the same time, to display the contents of different buffers or different portions of a single buffer.

10.1.3. Point and Mark

When you are editing in Emacs, the position of the cursor is known as point. You can set a mark at another place in the text to operate on the region between point and mark. This is a very useful feature for such operations as deleting or moving an area of text.

10.1.4. Kill and Yank

Emacs uses the terms kill and yank for the concepts more commonly known today as cut and paste. You cut text in Emacs by killing it, and paste it by yanking it back. If you do multiple kills in a row, you can yank them back all at once.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.