You are on page 1of 2

GNU Emacs Reference Card Motion Multiple Windows

(for version 26) entity to move over backward forward When two commands are shown, the second is a similar com-
character C-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 26, 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
paragraph M-{ M-}
Leaving Emacs page C-x [ C-x ]
scroll other window C-M-v
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
scroll to next screen C-v find file read-only in other window C-x 4 r C-x 5 r
Files 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 C-x C-s grow window taller C-x ^
scroll current line to center, top, bottom C-l
save all files C-x s shrink window narrower C-x {
goto line M-g g grow window wider C-x }
insert contents of another file into this buffer C-x i
goto char M-g c
replace this file with the file you really want C-x C-v Formatting
back to indentation M-m
write buffer to a specified file C-x C-w
toggle read-only status of buffer C-x C-q indent current line (mode-dependent) TAB
Killing and Deleting indent region (mode-dependent) C-M-\
indent sexp (mode-dependent) C-M-q
Getting Help entity to kill backward forward
indent region rigidly arg columns C-x TAB
character (delete, not kill) DEL C-d
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
remove help window C-x 1 sexp M-- C-M-k C-M-k delete blank lines around point C-x C-o
scroll help window C-M-v join line with previous (with arg, next) M-^
kill region C-w
apropos: show commands matching a string C-h a delete all white space around point M-\
copy region to kill ring M-w
describe the function a key runs C-h k put exactly one space at point M-SPC
kill through next occurrence of char M-z char
describe a function C-h f fill paragraph M-q
yank back last thing killed C-y
get mode-specific information C-h m set fill column to arg C-x f
replace last yank with previous kill M-y
set prefix each line starts with C-x .
Error Recovery Marking set face M-o

abort partially typed or executing command C-g set mark here C-@ or C-SPC
Case Change
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
The Minibuffer
mark entire buffer C-x h
search forward C-s The following keys are defined in the minibuffer.
search backward C-r Query Replace complete as much as possible TAB
regular expression search C-M-s complete up to one word SPC
interactively replace a text string M-%
reverse regular expression search C-M-r complete and execute RET
using regular expressions M-x query-replace-regexp
select previous search string M-p show possible completions ?
Valid responses in query-replace mode are fetch previous minibuffer input M-p
select next later search string M-n
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 2018 Free Software 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)
Buffers zero or more repeats *
save region in register C-x r s
insert register contents into buffer C-x r i
select another buffer C-x b one or more repeats +
zero or one repeat ? save value of point in register C-x r SPC
list all buffers C-x C-b
quote special characters \ jump to point saved in register C-x r j
kill a buffer C-x k
quote regular expression special character c \c
Transposing alternative (“or”) \| Keyboard Macros
grouping \( . . . \)
transpose characters C-t shy grouping \(:? . . . \)
transpose words M-t start defining a keyboard macro C-x (
explicit numbered grouping \(:NUM . . . \)
transpose lines C-x C-t end keyboard macro definition C-x )
same text as nth group \n
transpose sexps C-M-t execute last-defined keyboard macro C-x e
at word break \b
append to last keyboard macro C-u C-x (
not at word break \B
Spelling Check name last keyboard macro M-x name-last-kbd-macro
entity match start match end insert Lisp definition in buffer M-x insert-kbd-macro
check spelling of current word M-$ line ^ $
check spelling of all words in region M-x ispell-region word \< \>
check spelling of entire buffer M-x ispell-buffer symbol \_< \_> Commands Dealing with Emacs Lisp
toggle on-the-fly spell checking M-x flyspell-mode buffer \‘ \’
class of characters match these match others eval sexp before point C-x C-e
Tags explicit set [ ... ] [^ . . . ] eval current defun C-M-x
word-syntax character \w \W eval region M-x eval-region
find a tag (a definition) M-. character with syntax c \sc \Sc read and eval minibuffer M-:
find next occurrence of tag C-u M-. character with category c \cc \Cc load a Lisp library from load-path M-x load-library
specify a new tags file M-x visit-tags-table
regexp search on all files in tags table M-x tags-search International Character Sets Simple Customization
run query-replace on all the files M-x tags-query-replace
specify principal language C-x RET l
continue last tags search or query-replace M-, customize variables and faces M-x customize
show all input methods M-x list-input-methods
enable or disable input method C-\
Shells set coding system for next command C-x RET c
Making global key bindings in Emacs Lisp (example):
(global-set-key (kbd "C-c g") ’search-forward)
execute a shell command M-! show all coding systems M-x list-coding-systems
(global-set-key (kbd "M-#") ’query-replace-regexp)
execute a shell command asynchronously M-& choose preferred coding system M-x prefer-coding-system
run a shell command on the region M-|
filter region through a shell command C-u M-| Info Writing Commands
start a shell in window *shell* M-x shell
enter the Info documentation reader C-h i
(defun command-name (args)
Rectangles find specified function or variable in Info C-h S
"documentation" (interactive "template")
Moving within a node: body)
copy rectangle to register C-x r r
scroll forward SPC
kill rectangle C-x r k An example:
scroll reverse DEL
yank rectangle C-x r y (defun this-line-to-top-of-window (line)
beginning of node b
open rectangle, shifting text right C-x r o "Reposition current line to top of window.
blank out rectangle C-x r c Moving between nodes:
With prefix argument LINE, put point on LINE."
prefix each line with a string C-x r t next node n (interactive "P")
previous node p (recenter (if (null line)
Abbrevs move up u 0
select menu item by name m (prefix-numeric-value line))))
add global abbrev C-x a g select nth menu item by number (1–9) n
add mode-local abbrev C-x a l follow cross reference (return with l) f The interactive spec says how to read arguments interacti-
add global expansion for this abbrev C-x a i g return to last node you saw l vely. Type C-h f interactive RET for more details.
add mode-local expansion for this abbrev C-x a i l return to directory node d
explicitly expand abbrev C-x a e go to top node of Info file t Copyright
c 2018 Free Software Foundation, Inc.
expand previous word dynamically M-/ go to any node by name g For GNU Emacs version 26
Designed by Stephen Gildea
Other:
Miscellaneous Released under the terms of the GNU General Public License version 3
run Info tutorial h or later.
numeric argument C-u num look up a subject in the indices i
For more Emacs documentation, and the TEX source for this card, see
negative argument M-- search nodes for regexp s
the Emacs distribution, or https://www.gnu.org/software/emacs
quoted insert C-q char quit Info q

You might also like