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

any single character except a newline . (dot) save region in register C-x r s Buffers 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 ( transpose characters C-t not at word break \B 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 Spelling Check class of characters match these match others explicit set [ ... ] [^ ... ] Commands Dealing with word-syntax character \w \W 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 C-x RET l 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 Simple Customization C-u M-. set coding system for next command C-x RET c specify a new tags file M-x visit-tags-table show all coding systems M-x list-coding-systems customize variables and faces M-x customize regexp search on all files in tags table M-x tags-search choose preferred coding system M-x prefer-coding-system run query-replace on all the files M-x tags-query-replace Making global key bindings in Emacs Lisp (example): continue last tags search or query-replace M-, (global-set-key (kbd "C-c g") ’search-forward) Info (global-set-key (kbd "M-#") ’query-replace-regexp) Shells enter the Info documentation reader C-h i find specified function or variable in Info C-h S Writing Commands execute a shell command M-! Moving within a node: run a shell command on the region M-| (defun command-name (args) filter region through a shell command C-u M-| scroll forward SPC "documentation" (interactive "template") start a shell in window *shell* M-x shell scroll reverse DEL body) beginning of node . (dot) An example: Moving between nodes: Rectangles (defun this-line-to-top-of-window (line) next node n "Reposition current line to top of window. copy rectangle to register C-x r r previous node p With ARG, put point on line ARG." kill rectangle C-x r k move up u (interactive "P") yank rectangle C-x r y select menu item by name m (recenter (if (null line) open rectangle, shifting text right C-x r o select nth menu item by number (1–9) n 0 blank out rectangle C-x r c follow cross reference (return with l) f (prefix-numeric-value line)))) prefix each line with a string C-x r t return to last node you saw l return to directory node d The interactive spec says how to read arguments interac- tively. Type C-h f interactive for more details. Abbrevs go to top node of Info file t go to any node by name g Copyright c 2010 , Inc. Other: For GNU Emacs version 23 add global abbrev C-x a g Designed by Stephen Gildea add mode-local abbrev C-x a l run Info tutorial h Permission is granted to make and distribute modified or unmodified add global expansion for this abbrev C-x a i g look up a subject in the indices i copies of this card provided the copyright notice and this permission add mode-local expansion for this abbrev C-x a i l search nodes for regexp s notice are preserved on all copies. explicitly expand abbrev C-x a e quit Info q For copies of the GNU Emacs manual, see: expand previous word dynamically M-/ http://www.gnu.org/software/emacs/#Manuals