Emacs Cheat Sheet

C- Ctrl M- Meta / Alt / Esc C-M- Ctrl+Meta C-x … Prefix chord SPC = Space · RET = Enter · DEL = Backspace

Movement — Char & Line

C-f / C-bForward / backward char
C-n / C-pNext / previous line
C-a / C-eBeginning / end of line
C-v / M-vScroll down / up (page)
C-lRecenter

Movement — Word & Sexp

M-f / M-bForward / backward word
M-a / M-eBeginning / end of sentence
C-M-f / C-M-bForward / backward sexp
C-M-a / C-M-eBeginning / end of defun
C-M-n / C-M-pForward / backward list
C-M-u / C-M-dUp / down in list

Movement — Buffer & Position

M-< / M->Beginning / end of buffer
M-g gGo to line number
M-g cGo to char position
C-x C-nSet/unset goal column
C-M-lReposition screen sensibly

Editing — Basic

C-dDelete char forward
DELDelete char backward
C-tTranspose chars
M-tTranspose words
C-M-tTranspose sexps
M-qFill / reflow paragraph
C-/ or C-x uUndo

Editing — Case & Comments

M-uUpcase word
M-lDowncase word
M-cCapitalize word
C-x C-uUpcase region
C-x C-lDowncase region
M-;Comment / uncomment
C-x C-;Toggle comment line

Killing (Cut)

C-kKill to end of line
C-wKill region
M-dKill word forward
M-DELKill word backward
M-kKill to end of sentence
C-M-kKill sexp
M-z charZap to char
C-x r kKill rectangle

Yanking (Paste) & Registers

C-yYank (paste) last killed
M-yCycle kill ring (after C-y)
M-wCopy region (no kill)
C-x r yYank rectangle
C-x r s rCopy region to register
C-x r i rInsert register

Mark & Region

C-SPCSet / activate mark
C-x C-xExchange point & mark
C-x hMark whole buffer
M-hMark paragraph
C-M-hMark defun
C-x r SPC rSave point to register
C-x r j rJump to register

Search & Replace

C-sIsearch forward
C-rIsearch backward
C-M-sRegexp isearch forward
C-M-rRegexp isearch backward
M-%Query replace
C-M-%Regexp query replace
M-x occurList matching lines

Files

C-x C-fFind / open file
C-x C-sSave buffer
C-x C-wWrite / save as
C-x sSave some buffers
C-x C-rFind file read-only
C-x C-vFind alternate file
C-x iInsert file at point

Buffers

C-x bSwitch to buffer
C-x C-bList all buffers
C-x kKill buffer
C-x ← / C-x →Previous / next buffer
M-x ibufferInteractive buffer manager
M-x rename-bufferRename buffer

Windows

C-x 2Split horizontally (above/below)
C-x 3Split vertically (side by side)
C-x 1Delete other windows
C-x 0Delete this window
C-x oCycle to other window
C-x ^Enlarge window vertically
C-x { / C-x }Shrink / enlarge width
C-x 4 fFind file in other window

Keyboard Macros

F3 or C-x (Start recording
F4 or C-x )Stop recording
C-x eExecute last macro
C-u N C-x eExecute macro N times
C-x C-k nName last macro
C-x C-k bBind macro to key
C-x C-k eEdit last macro

Help

C-h kDescribe key binding
C-h fDescribe function
C-h vDescribe variable
C-h mDescribe current mode(s)
C-h aApropos — search commands
C-h iOpen Info manual browser
C-h lShow last 300 keystrokes
C-h C-hHelp for help

Misc & Global

M-xExecute command by name
C-gQuit / cancel minibuffer
C-x C-cExit Emacs
C-zSuspend / iconify Emacs
C-uUniversal arg prefix (×4)
C-u NRepeat next command N times
M-!Run shell command
M-&Run shell command async