While vi (with its clones) is without a doubt the most ubiquitous editor on Unix-like systems, Emacs comes in a good second. Instead of using different “modes”, like vi does, it uses Control and Alt key combinations to enter commands, in much the same way that you can use Control and Alt key combinations in a word processor and indeed in many other applications to execute certain functions. (Though it should be noted that the commands rarely correspond; so while many modern applications use Ctrl-C/ X/ V for copying, cutting and pasting, Emacs uses different keys and actually a somewhat different mechanism for this.)
Also unlike vi, which is an (excellent) editor and nothing more, Emacs is a program with near endless capabilities. Emacs is (for the most part) written in Lisp, which is a very powerful programming language that has the peculiar property that every program written in it is automatically a Lisp compiler of its own. This means that the user can extend Emacs, and in fact write completely new programs “in Emacs”.
As a result, Emacs is not just an editor anymore. There are many add-on packages for Emacs available (many come with the program's source) that provide all sorts of functionality. Many of these are related to text editing, which is after all Emacs' basic task, but it doesn't stop there. There are for example several spreadsheet programs for Emacs, there are databases, games, mail and news clients (the top one being Gnus), etc.
There are two main versions of Emacs: GNU Emacs (which is the version that comes with Slackware) and XEmacs. The latter is not a version for Emacs running under X. In fact, both Emacs and XEmacs run on the console as well as under X. XEmacs was once started as a project to tidy up the Emacs code. Currently, both versions are being actively developed, and there is in fact much interaction between the two development teams. For the present chapter, it is immaterial whether you use Emacs or XEmacs, the differences between them are not relevant to the normal user.
Emacs can be started from the shell by simply typing emacs. When you are running X, Emacs will (normally) come up with its own X window, usually with a menu bar at the top, where you can find the most important functions. On startup, Emacs will first show a welcome message, and then after a few seconds will drop you in the *scratch* buffer. (See Section 17.2.)
You can also start Emacs on an existing file by typing
% emacs /etc/resolv.conf |
This will cause Emacs to load the specified file when it starts up, skipping the welcome message.
As mentioned above, Emacs uses Control and Alt combinations for commands. The usual convention is to write these with C-letter and M-letter, respectively. So C-x means Control+x, and M-x means Alt+x. (The letter M is used instead of A because originally the key was not the Alt key but the Meta key. The Meta key has all but disappeared from computer keyboards, and in Emacs the Alt key has taken over its function.)
Many Emacs commands consist of sequences of keys and key combinations. For example, C-x C-c (that is Control-x followed by Control-c ) quits Emacs, C-x C-s saves the current file. Keep in mind that C-x C-b is not the same as C-x b. The former means Control-x followed by Control-b, while the latter means Control-x followed by just 'b'.