You are on page 1of 2

GNU Emacs Reference Card Motion Multiple Windows

(for version 28) 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.
Key Binding Notation 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
In the Emacs key binding notation, C-x is Ctrl+X; M-x is usually go to line beginning (or end) C-a C-e delete this window C-x 0 C-x 5 0
Alt+X; S-x is Shift+X; and C-M-x is Ctrl+Alt+X, etc. sentence M-a M-e split window, side by side C-x 3
paragraph M-{ M-}
scroll other window C-M-v
Leaving Emacs page C-x [ C-x ]
sexp C-M-b C-M-f switch cursor to another window C-x o C-x 5 o
function C-M-a C-M-e select buffer in other window C-x 4 b C-x 5 b
iconify Emacs (or suspend it in terminal) C-z
go to buffer beginning (or end) M-< M-> display buffer in other window C-x 4 C-o C-x 5 C-o
exit Emacs permanently C-x C-c
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 >
scroll current line to center, top, bottom C-l grow window taller C-x ^
save a file back to disk C-x C-s shrink window narrower C-x {
save all files C-x s 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 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
rections. If you are a first-time user, type C-h t for a tutorial. insert newline after point C-o
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 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
Case Change
abort partially typed or executing command C-g set mark here C-@ or C-SPC
exchange point and mark C-x C-x uppercase word M-u
recover files lost by a system crash M-x recover-session lowercase word M-l
undo an unwanted change C-x u, C-_ or C-/ set mark arg words away M-@ capitalize word M-c
restore a buffer to its original contents M-x revert-buffer mark paragraph M-h
redraw garbaged screen uppercase region C-x C-u
C-l mark page C-x C-p
lowercase region C-x C-l
mark sexp C-M-@
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
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
show possible completions ?
select previous search string M-p Valid responses in query-replace mode are fetch previous minibuffer input M-p
select next search string M-n
replace this one, go on to next SPC or y fetch later minibuffer input or default M-n
exit incremental search RET
replace this one, don’t move , regexp search backward through history M-r
undo effect of last character DEL
skip to next without replacing DEL or n regexp search forward through history M-s
abort current search C-g
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 2022 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 \(?: . . . \)
start defining a keyboard macro C-x (
transpose words M-t explicit numbered grouping \(?NUM: . . . \)
end keyboard macro definition C-x )
transpose lines C-x C-t same text as nth group \n
execute last-defined keyboard macro C-x e
transpose sexps C-M-t at word break \b
append to last keyboard macro C-u C-x (
not at word break \B
name last keyboard macro M-x name-last-kbd-macro
Spelling Check entity match start match end insert Lisp definition in buffer M-x insert-kbd-macro
line ^ $
check spelling of current word M-$
word \< \>
check spelling of all words in region M-x ispell-region
symbol \_< \_> Commands Dealing with Emacs Lisp
check spelling of entire buffer M-x ispell-buffer
buffer \‘ \’
toggle on-the-fly spell checking M-x flyspell-mode eval sexp before point C-x C-e
class of characters match these match others
explicit set [ ... ] [^ . . . ] eval current defun C-M-x
Tags word-syntax character \w \W eval region M-x eval-region
character with syntax c \sc \Sc read and eval minibuffer M-:
find a tag (a definition) 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
run query-replace on all the files M-x tags-query-replace
International Character Sets Simple Customization
continue last tags search or query-replace M-, specify principal language C-x RET l
show all input methods M-x list-input-methods customize variables and faces M-x customize
Shells enable or disable input method C-\ Making global key bindings in Emacs Lisp (example):
set coding system for next command C-x RET c
execute a shell command M-! (global-set-key (kbd "C-c g") ’search-forward)
show all coding systems M-x list-coding-systems
execute a shell command asynchronously M-& (global-set-key (kbd "M-#") ’query-replace-regexp)
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
start a shell in window *shell* M-x shell
Writing Commands
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
kill rectangle C-x r k scroll forward SPC
An example:
yank rectangle C-x r y scroll reverse DEL
open rectangle, shifting text right C-x r o beginning of node b (defun this-line-to-top-of-window (line)
blank out rectangle "Reposition current line to top of window.
C-x r c Moving between nodes:
prefix each line with a string C-x r t With prefix argument LINE, put point on LINE."
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 The interactive spec says how to read arguments interac-
follow cross reference (return with l) f
add global expansion for this abbrev C-x a i g tively. Type C-h f interactive RET for more details.
return to last node you saw l
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 2022 Free Software Foundation, Inc.
expand previous word dynamically M-/ go to any node by name g For GNU Emacs version 28
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