Emacs cheat sheet

← Home
  1. Cursor motion
  2. Cut/copy/paste
  3. Searching and replacing
  4. Files
  5. Buffers
  6. Scrolling
  7. Windows
  8. Miscellaneous
  9. Getting help
flagup

Cheat sheet

Cursor motion

Move… Delete…
Amount …forward …backward …forward …backward
Characters C-f C-b C-d DEL
Words M-f or M-RIGHT M-b or M-LEFT M-d M-DEL
Lines C-n C-p C-S-BACKSPACE
Sentences M-e M-a M-k C-x BACKSPACE
Expressions C-M-f C-M-b C-M-k C-M-DEL
Paragraphs M-} M-{
End/start of line C-e or END C-a or HOME
End/start of buffer M-> M-<

Cut/copy/paste

C-SPC Mark one end of region. Functions below will not work without marked region
C-w Cut
M-w Copy
C-y Yank (paste)

Searching and replacing

C-s Incremental search forward (searches as you type). If search string is empty, jumps to the next occurrence found previously
C-r Incremental search backward (searches as you type). If search string is empty, jumps to the previous occurrence found previously
C-M-s Regexp search forward (searches as you type)
C-M-r Regexp search backward (searches as you type)
M-x replace-string Replace string from cursor to end of buffer (prompts for string and replacement)
M-x query-replace Replace string from cursor to end of buffer (querying for each occurrence)

Files

C-x C-f Find or create new file
C-x C-s Save file
C-x C-w Write file (prompts for new name)

Buffers

C-x C-b List buffers (in other window)
C-x b Select buffer (prompts for buffer name)
C-x s Save current buffer (prompts for buffer name)
C-x k Kill buffer (prompts for buffer name)

Scrolling

C-v Scroll one screen size down
M-v Scroll one screen size up

Windows

C-x 0 Close current window
C-x 2 Split window vertically
C-x 3 Split window horizontally
C-x o Next window
M-x prev-window Previous window

Miscellaneous

ESC ESC ESC Get me out of where I am now
C-_ or C-x u Undo. After doing something else will undo the undo's
C-x C-c Exit Emacs (asks about unsaved buffers and running programs)

Getting help

C-h k Show command documentation (prompts for keystrokes)
C-h c Show brief command description on message line (prompts for keystrokes)
C-h a Runs apropos-command (prompts for regexp and shows all matching commands)
C-h f Runs describe-function (prompts for command or function name, shows documentation in other window)
C-h i Info browser (gives access to online documentation for Emacs and more)

Some useful links

made with emacs
Last update: