A very common problem is that the Del or Backspace key on the terminal does not delete the character before the cursor, as it should. Instead, it invokes a help prompt. This problem is caused by an incompatible terminal. A fairly robust fix is to create a file named .emacs in your home directory (or edit one that's already there) and add the following lines:
(keyboard-translate ?\C-h ?\C-?) (keyboard-translate ?\C-\\ ?\C-h)
Now the Del or Backspace kill should work, and you can invoke help by pressing C-\ (an arbitrarily chosen key sequence).
Another potential problem is that on some systems, C-s causes the terminal to hang. This is due to an old-fashioned handshake protocol between the terminal and the system. You can restart the terminal by pressing C-q, but that doesn't help you enter commands that contain the sequence C-s. The solution (aside from using a more modern dial-in protocol) is to create new key bindings that replace C-s or to enter those commands as M-x command-name.
Emacs commands use the Ctrl key and the Meta key. Most modern terminals provide a key named Alt that functions as a Meta key. In this section, the notation C- indicates that you should hold down the Ctrl key and press the character that follows, while M- indicates that the Meta or Alt key is pressed in the same way, along with the character that follows. As an alternative to Meta or Alt, you can press the Esc key, release it, and press the character. You might want to do this if you have any problems with controlling windows capturing the Alt key (which sometimes happens).
In the command tables that follow, the first column lists the keystroke and the last column describes it. When there is a middle column, it lists the command name. The command can be executed by typing M-x followed by the command name; you have to do this when the binding is listed as "(none)." If you're unsure of the full command name, you can type a space or a carriage return, and Emacs will list possible completions of what you've typed so far.
Because Emacs is such a comprehensive editor, containing hundreds of commands, some commands must be omitted for the sake of preserving a "quick" reference. You can browse the command set by typing C-h (for help) and then b to get a list of the key bindings[6] or M-x followed by a space or Tab to get the command names.
[6]If you want to learn to create your own key bindings, see Learning GNU Emacs (O'Reilly).
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 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 mode is Dired (Directory Editor), which has commands that let you manage directories. For a full discussion of modes, see Learning GNU Emacs, mentioned at the beginning of this chapter, or the Emacs Info documentation system (C-h i).
If you're just getting started with Emacs, here's a short list of the most important commands to know:
Binding | Action |
---|---|
C-h | Enter the online help system. |
C-x C-s | Save the file. |
C-x C-c | Exit Emacs. |
C-x u | Undo last edit (can be repeated). |
C-g | Get out of current command operation. |
C-p | Up by one line. |
C-n | Down by one line. |
C-f | Forward by one character. |
C-b | Back by one character. |
C-v | Forward by one screen. |
M-v | Backward by one screen. |
C-s | Search forward for characters. |
C-r | Search backward for characters. |
C-d | Delete current character. |
Del | Delete previous character. |
Backspace | Delete previous character. |
Copyright © 2001 O'Reilly & Associates. All rights reserved.