GNU Reference Card Motion Multiple Windows (for version 24) entity to move over backward forward When two commands are shown, the second is a similar com- character -b C-f mand for a frame instead of a window. 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 24, 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 sexp C-M-b C-M-f suspend Emacs (or iconify it under X) C-z select buffer in other window C-x 4 b C-x 5 b function C-M-a C-M-e exit Emacs permanently C-x C-c 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 scroll left C-x < find tag in other window C-x 4 . C-x 5 . read a file into Emacs C-x C-f scroll right C-x > save a file back to disk grow window taller C-x ^ C-x C-s scroll current line to center, top, bottom C-l save all files C-x s shrink window narrower C-x { insert contents of another file into this buffer C-x i goto line M-g g grow window wider C-x } replace this file with the file you really want C-x C-v back to indentation M-m Formatting write buffer to a specified file C-x C-w toggle read-only status of buffer C-x C-q Killing and Deleting indent current line (mode-dependent) TAB indent region (mode-dependent) C-M-\ entity to kill backward forward indent sexp (mode-dependent) C-M-q Getting Help character (delete, not kill) DEL C-d indent region rigidly arg columns C-x TAB word M-DEL M-d indent for comment M-; The help system is simple. Type C-h (or F1) and follow the di- line (to end of) M-0 C-k C-k insert newline after point C-o rections. If you are a first-time user, type C-h t for a tutorial. sentence C-x DEL M-k move rest of line vertically down C-M-o sexp M-- C-M-k C-M-k remove help window C-x 1 delete blank lines around point C-x C-o scroll help window C-M-v kill region C-w join line with previous (with arg, next) M-^ apropos: show commands matching a string C-h a copy region to kill ring M-w delete all white space around point M-\ describe the function a key runs C-h k kill through next occurrence of char M-z char put exactly one space at point M-SPC describe a function C-h f yank back last thing killed C-y fill paragraph M-q get mode-specific information C-h m replace last yank with previous kill M-y set fill column to arg C-x f set prefix each line starts with C-x . Error Recovery Marking set face M-o Case Change abort partially typed or executing command C-g set mark here C-@ or C-SPC recover files lost by a system crash M-x recover-session exchange point and mark C-x C-x uppercase word M-u undo an unwanted change C-x u, C-_ or C-/ set mark arg words away M-@ lowercase word M-l restore a buffer to its original contents M-x revert-buffer mark paragraph M-h capitalize word M-c redraw garbaged screen C-l mark page C-x C-p uppercase region C-x C-u mark sexp C-M-@ lowercase region C-x C-l Incremental Search mark function C-M-h mark entire buffer C-x h The Minibuffer search forward C-s The following keys are defined in the minibuffer. search backward C-r Query Replace complete as much as possible TAB complete up to one word regular expression search C-M-s interactively replace a text string M-% SPC complete and execute reverse regular expression search C-M-r using regular expressions M-x query-replace-regexp RET show possible completions ? select previous search string M-p Valid responses in query-replace mode are select next later search string M-n fetch previous minibuffer input M-p exit incremental search RET replace this one, go on to next SPC or y fetch later minibuffer input or default M-n undo effect of last character DEL replace this one, don’t move , regexp search backward through history M-r abort current search C-g skip to next without replacing DEL or n regexp search forward through history 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 2012 Foundation, Inc. Permissions on back. enter recursive edit (C-M-c to exit) C-r text terminals. GNU Emacs Reference Card Regular Expressions Registers Buffers any single character except a newline . (dot) save region in register C-x r s zero or more repeats * insert register contents into buffer C-x r i select another buffer C-x b one or more repeats + save value of point in register C-x r SPC list all buffers C-x C-b zero or one repeat ? jump to point saved in register C-x r j kill a buffer C-x k quote regular expression special character c \c alternative (“or”) \| Transposing grouping \( ... \) Keyboard Macros same text as nth group \n transpose characters C-t at word break \b start defining a keyboard macro C-x ( transpose words M-t not at word break \B end keyboard macro definition C-x ) transpose lines C-x C-t entity match start match end execute last-defined keyboard macro C-x e transpose sexps C-M-t line ^ $ append to last keyboard macro C-u C-x ( word \< \> name last keyboard macro M-x name-last-kbd-macro Spelling Check buffer \‘ \’ insert Lisp definition in buffer M-x insert-kbd-macro check spelling of current word M-$ class of characters match these match others check spelling of all words in region M-x ispell-region explicit set [ ... ] [^ ... ] Commands Dealing with check spelling of entire buffer M-x ispell-buffer word-syntax character \w \W character with syntax c \sc \Sc eval sexp before point C-x C-e Tags eval current defun C-M-x International Character Sets eval region M-x eval-region find a tag (a definition) M-. read and eval minibuffer M-: find next occurrence of tag C-u M-. specify principal language C-x RET l load from standard system M-x load-library specify a new tags file M-x visit-tags-table show all input methods M-x list-input-methods regexp search on all files in tags table M-x tags-search enable or disable input method C-\ Simple Customization run query-replace on all the files M-x tags-query-replace set coding system for next command C-x RET c continue last tags search or query-replace M-, show all coding systems M-x list-coding-systems customize variables and faces M-x customize choose preferred coding system M-x prefer-coding-system Shells Making global key bindings in Emacs Lisp (example): (global-set-key (kbd "C-c g") ’search-forward) execute a shell command M-! Info (global-set-key (kbd "M-#") ’query-replace-regexp) run a shell command on the region M-| filter region through a shell command C-u M-| enter the Info documentation reader C-h i start a shell in window *shell* M-x shell find specified function or variable in Info C-h S Writing Commands Moving within a node: Rectangles (defun command-name (args) scroll forward SPC "documentation" (interactive "template") copy rectangle to register C-x r r scroll reverse DEL body) kill rectangle C-x r k beginning of node . (dot) An example: yank rectangle C-x r y Moving between nodes: open rectangle, shifting text right C-x r o (defun this-line-to-top-of-window (line) next node n blank out rectangle C-x r c "Reposition current line to top of window. previous node p prefix each line with a string C-x r t With ARG, put point on line ARG." move up u (interactive "P") Abbrevs select menu item by name m (recenter (if (null line) select nth menu item by number (1–9) n 0 add global abbrev C-x a g follow cross reference (return with l) f (prefix-numeric-value line)))) add mode-local abbrev C-x a l return to last node you saw l return to directory node d The interactive spec says how to read arguments interac- add global expansion for this abbrev C-x a i g tively. Type C-h f interactive for more details. add mode-local expansion for this abbrev C-x a i l go to top node of Info file t go to any node by name explicitly expand abbrev C-x a e g Copyright c 2012 , Inc. Other: For GNU Emacs version 24 expand previous word dynamically M-/ Designed by Stephen Gildea run Info tutorial h Permission is granted to make and distribute modified or unmodified Miscellaneous look up a subject in the indices i copies of this card provided the copyright notice and this permission search nodes for regexp s notice are preserved on all copies. numeric argument C-u num quit Info q For copies of the GNU Emacs manual, see: negative argument M-- quoted insert C-q char http://www.gnu.org/software/emacs/#Manuals