Emacs ******************************************************************** Emacs is a widely available text editor. There are several different versions, but all have certain similarities. Emacs begins in the "insert" mode, i.e., unless you let the system know otherwise, characters are assumed to be entered as part of the text. Certain non-printing control or escape characters indicate Emacs commands follow. The main control keys are Esc and Ctrl. The bindings are represented by C- for control key bindings, and M- for Meta key bindings. The Meta key on most keyboards is the Escape key. Many Emacs commands are bound to keys that are to be entered following a control key. Other Emacs commands are entered in a command buffer that is brought up by entering the sequence M-x (Esc followed by x). Most Emacs function names are multiple words, separated by hyphens; e.g., "describe-variable" or "save-buffers-kill-emacs." Control key bindings are entered by holding down the Ctrl key, and then pressing the given key. For instance, C-v is bound to "scroll-down." To scroll downwards through the text, simply hold down the Ctrl key and then press the v key. Meta key sequences, on the other hand, differ depending on the meta key. On VAXstations, M-% (query-replace) is invoked by holding down the Compose Character key and pressing the % key. On a terminal using the Escape key, press and release the Escape key, and then press %. Some commands are accessed through multiple Meta and Control sequences. To save all buffers and exit Emacs, for example, use the two-key sequence C-x C-c. All Emacs commands can be bound to multiple or different keys, using other Emacs commands, or a startup file (often called .emacs or emacsrc). A list of all current bindings can be seen by invoking describe-bindings, which is usually bound to C-h b (the two-key sequence of a Ctrl-h, followed by a b). I have the 12 function keys (and their Shift- and Ctrl- versions) bound to 36 common actions on my Unix machine and all of my PCs, including my HP 200LX palmtop. All commands can be invoked directly by using the M-x command (this is the only way to invoke a command that has no binding). This gives a prompt at the bottom of the screen, and the name of the command to be executed should be entered there. ----------------------------------------------------------------------------- Help in Emacs The help prefix is C-h. Typing C-h C-h will give a list of possible help options; typing C-h three times gives a short description of each help option. C-h t will start the tutorial. (The choice of C-h was unfortunate, because the Backspace key on many systems generates the sequence C-h. It is sometimes necessary just to accept the mistakes of provincial software designers.) Function Binding -------------------------------------- command-apropos C-h a describe-key-briefly C-h c key info C-h i describe-mode C-h m help-with-tutorial C-h t where-is C-h w describe-bindings C-h b describe-function C-h f describe-key C-h k view-emacs-news C-h n describe-variable C-h v ----------------------------------------------------------------------------- Moving the Cursor Moving the cursor in Emacs is a little different than with most text editors--rather than placing the keys in a sort of diamond or row, Emacs uses (in most cases) letters which correspond to English words, to make their functions easier to remember. Some commands deal not with characters, but with English constructs like words or sentences. These are often the same letter as an analogous character-based function, but with a Meta key instead of a Control key. Function Binding -------------------------------------- previous-line C-p next-line C-n forward-char C-f forward-word M-f backward-char C-b backward-word M-b beginning-of-line C-a recenter C-l backward-sentence M-a end-of-line C-e forward-sentence M-e scroll-down C-v scroll-up M-v beginning-of-buffer M-< end-of-buffer M-> transpose-chars C-t ----------------------------------------------------------------------------- Cutting, Copying, and Pasting When you delete a line, it is stored in a kill ring, which basically is a list of all recent deletions. Text stored in the kill ring can be yanked back into the document at a later time by using Ctrl-y. To yank something other than the most recent kill, use Meta-y (yank-pop), after first yanking with C-y. Each time M- y is used, the last deletion is removed from the screen and replaced with the previous deletion. In this way you can cut and paste several different blocks of text at once. To copy a block, just delete it, yank it, and then move to where it should be copied, and yank it again. Only commands with "kill" in their name get stored in the kill ring--that is, simply deleting 20 characters with C-d won't work. Function Binding -------------------------------------- delete-char C-d kill-word M-d kill-line C-k kill-sentence M-k open-line C-o undo C-x u isearch-forward C-s yank C-y yank-pop M-y delete-backward-char DEL backward-kill-word M-DEL delete-blank-lines C-x C-o query-replace M-% isearch-backward C-r ----------------------------------------------------------------------------- Files, Buffers, and Windows Emacs can work with several files at once, each with its own named buffer. The name of the current buffer is shown in the control line at the bottom of the screen. To load a file into the current buffer, use C-x C-f. You will then be prompted for the filename. Also, Emacs can split the screen into different windows, and put different buffers (files) in each window. There are several functions relating to windows, and most operate relative to the current window (where the cursor is). A region is the space between the cursor and a mark, which may be set by using C-c C-c (or C-Space if your terminal allows it, or Ctrl with most numeric keys if you're using a modem). Function Binding -------------------------------------- find-file C-x C-f save-buffer C-x C-s save-some-buffers C-x s switch-to-buffer C-x b list-buffers C-x C-b kill-buffer C-x k kill-some-buffers (none) find-alternate-file C-x C-v write-file C-x C-w save-buffers-kill-emacs C-x C-c list-directory C-x C-d insert-file (none) split-window-vertically C-x 2 delete-other-windows C-x 1 kill-window C-x 0 other-window C-x o enlarge-window C-x ^ set-mark C-c C-c write-region (none)