GNU Reference Card Motion Multiple Windows (for version 20) entity to move over backward forward When two commands are shown, the second is for “other frame.” character -b C-f delete all other windows C-x 1 Starting Emacs word M-b M-f split window, above and below C-x 2 C-x 5 2 line C-p C-n delete this window C-x 0 C-x 5 0 To enter GNU Emacs 20, just type its name: emacs go to line beginning (or end) C-a C-e split window, side by side C-x 3 To read in a file to edit, see Files, below. sentence M-a M-e paragraph M-{ M-} scroll other window C-M-v page C-x [ C-x ] switch cursor to another window C-x o C-x 5 o Leaving Emacs sexp C-M-b C-M-f select buffer in other window C-x 4 b C-x 5 b function C-M-a C-M-e display buffer in other window C-x 4 C-o C-x 5 C-o suspend Emacs (or iconify it under X) C-z go to buffer beginning (or end) M-< M-> find file in other window C-x 4 f C-x 5 f exit Emacs permanently C-x C-c scroll to next screen C-v find file read-only in other window C-x 4 r C-x 5 r scroll to previous screen M-v run Dired in other window C-x 4 d C-x 5 d Files scroll left C-x < find tag in other window C-x 4 . C-x 5 . scroll right C-x > grow window taller C-x ^ read a file into Emacs C-x C-f scroll current line to center of screen C-u C-l shrink window narrower C-x { save a file back to disk C-x C-s grow window wider C-x } save all files C-x s Killing and Deleting insert contents of another file into this buffer C-x i Formatting replace this file with the file you really want C-x C-v entity to kill backward forward write buffer to a specified file C-x C-w indent current line (mode-dependent) TAB character (delete, not kill) DEL C-d version control checkin/checkout C-x C-q indent region (mode-dependent) C-M-\ word M-DEL M-d indent sexp (mode-dependent) C-M-q line (to end of) M-0 C-k C-k indent region rigidly arg columns C-x TAB Getting Help sentence C-x DEL M-k sexp M-- C-M-k C-M-k insert newline after point C-o C-M-o The help system is simple. Type C-h (or F1) and follow the di- move rest of line vertically down kill region C-w C-x C-o rections. If you are a first-time user, type C-h t for a tutorial. delete blank lines around point copy region to kill ring M-w join line with previous (with arg, next) M-^ remove help window C-x 1 kill through next occurrence of char M-z char delete all white space around point M-\ scroll help window C-M-v yank back last thing killed C-y put exactly one space at point M-SPC apropos: show commands matching a string C-h a replace last yank with previous kill M-y fill paragraph M-q show the function a key runs C-h c set fill column C-x f describe a function C-h f set prefix each line starts with C-x . C-h m Marking get mode-specific information set face M-g set mark here C-@ or C-SPC Error Recovery exchange point and mark C-x C-x Case Change arg words M-@ abort partially typed or executing command C-g set mark away uppercase word M-u paragraph M-h recover a file lost by a system crash M-x recover-file mark lowercase word M-l page C-x C-p undo an unwanted change C-x u or C-_ mark capitalize word M-c sexp C-M-@ restore a buffer to its original contents M-x revert-buffer mark function C-M-h uppercase region C-x C-u redraw garbaged screen C-l mark mark entire buffer C-x h lowercase region C-x C-l Incremental Search Query Replace The Minibuer search forward C-s The following keys are defined in the minibuffer. search backward C-r interactively replace a text string M-% complete as much as possible TAB regular expression search C-M-s using regular expressions M-x query-replace-regexp complete up to one word SPC reverse regular expression search C-M-r Valid responses in query-replace mode are complete and execute RET show possible completions ? select previous search string M-p replace this one, go on to next SPC fetch previous minibuffer input M-p select next later search string M-n replace this one, don’t move , fetch later minibuffer input or default M-n exit incremental search RET skip to next without replacing DEL regexp search backward through history M-r undo effect of last character DEL replace all remaining matches ! regexp search forward through history M-s abort current search C-g back up to the previous match ^ abort command C-g Use C-s or C-r again to repeat the search in either direction. exit query-replace RET Type C-x ESC ESC to edit and repeat the last command that If Emacs is still searching, C-g cancels only the part not done. enter recursive edit (C-M-c to exit) C-r used the minibuffer. Type F10 to activate the menu bar using c 1997 Foundation, Inc. Permissions on back. v2.2 the minibuffer. 1 2 3 GNU Emacs Reference Card Regular Expressions Registers

any single character except a newline . (dot) save region in register C-x r s Buers zero or more repeats * insert register contents into buffer C-x r i one or more repeats + save value of point in register C-x r SPC select another buffer C-x b zero or one repeat ? jump to point saved in register C-x r j list all buffers C-x C-b quote regular expression special character c \c kill a buffer C-x k alternative (“or”) \| grouping \( . . . \) Keyboard Macros Transposing same text as nth group \n at word break \b start defining a keyboard macro C-x ( not at word break \B transpose characters C-t end keyboard macro definition C-x ) transpose words M-t entity match start match end execute last-defined keyboard macro C-x e transpose lines C-x C-t line ^ $ append to last keyboard macro C-u C-x ( transpose sexps C-M-t word \< \> name last keyboard macro M-x name-last-kbd-macro buffer \‘ \’ insert Lisp definition in buffer M-x insert-kbd-macro class of characters match these match others Spelling Check explicit set [ . . . ] [^ . . . ] word-syntax character \w \W Commands Dealing with check spelling of current word M-$ character with syntax c \sc \Sc check spelling of all words in region M-x ispell-region eval sexp before point C-x C-e check spelling of entire buffer M-x ispell-buffer eval current defun C-M-x International Character Sets eval region M-x eval-region read and eval minibuffer M-: Tags specify principal language M-x set-language-environment load from standard system M-x load-library show all input methods M-x list-input-methods find a tag (a definition) M-. enable or disable input method C-\ find next occurrence of tag C-u M-. set coding system for next command C-x RET c Simple Customization specify a new tags file M-x visit-tags-table show all coding systems M-x list-coding-systems choose preferred coding system M-x prefer-coding-system customize variables and faces M-x customize regexp search on all files in tags table M-x tags-search run query-replace on all the files M-x tags-query-replace Making global key bindings in Emacs Lisp (examples): continue last tags search or query-replace M-, Info (global-set-key "\C-cg" ’goto-line) (global-set-key "\M-#" ’query-replace-regexp) Shells enter the Info documentation reader C-h i find specified function or variable in Info C-h C-i Writing Commands execute a shell command M-! Moving within a node: run a shell command on the region M-| scroll forward SPC (defun command-name (args) filter region through a shell command C-u M-| scroll reverse DEL "documentation" (interactive "template") start a shell in window *shell* M-x shell beginning of node . (dot) body) An example: Rectangles Moving between nodes: next node n (defun this-line-to-top-of-window (line) previous node p "Reposition line point is on to top of window. copy rectangle to register C-x r r move up u With ARG, put point on line ARG." kill rectangle C-x r k select menu item by name m (interactive "P") yank rectangle C-x r y select nth menu item by number (1–9) n (recenter (if (null line) open rectangle, shifting text right C-x r o follow cross reference (return with l) f 0 blank out rectangle C-x r c return to last node you saw l (prefix-numeric-value line)))) prefix each line with a string C-x r t return to directory node d The interactive spec says how to read arguments interac- go to any node by name g tively. Type C-h f interactive for more details. Abbrevs Other: run Info tutorial h Copyright c 1997 , Inc. add global abbrev C-x a g quit Info q C-x a l v2.2 for GNU Emacs version 20, June 1997 add mode-local abbrev search nodes for regexp M-s designed by Stephen Gildea add global expansion for this abbrev C-x a i g Permission is granted to make and distribute copies of this card pro- add mode-local expansion for this abbrev C-x a i l vided the copyright notice and this permission notice are preserved on explicitly expand abbrev C-x a e all copies. expand previous word dynamically M-/ For copies of the GNU Emacs manual, write to the Free Software Foun- dation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

4 5 6