Emacs Core Keyboard Shortcuts
I created this cheat sheet for my own use, based on the emacs built-in tutorial, but feel free to use it if you find it helpful.
- C-x C-c
- End the emacs session.
- C-g
- Quit a partially-entered command.
- C-x k
- Stop the tutorial.
- C-v
- Move forward one screenful, or scroll text down by the number of lines provided with C-u (e.g. C-u 8 C-v).
- M-v
- Move backward one screenful, or scroll text up by the number of lines provided with C-u (e.g. Cu 8 M-v).
- C-l
- Clear screen and redisplay all the text, moving the text around the cursor to the center of the screen. Repeating moves cursor text to top, and again moves to bottom.
- C-h k [sc]
- Display documentation about a keyboard shortcut in a new window.
Basic Cursor Control
- C-p
- Move to the previous line.
- C-n
- Move to the next line.
- C-f
- Move forward a character.
- C-b
- Move backward a character.
- M-f
- Move forward a word.
- M-b
- Move backward a word.
- C-a
- Move to the beginning of the line.
- C-e
- Move to the end of the line.
- M-a
- Move to the beginning of a sentence.
- M-e
- Move to the end of a sentence.
- M-<
- Move to the beginning of the whole text (need to use the shift key.)
- M->
- Move to the end of the whole text (need to use the shift key).
Windows
- C-x 1
- Kill all other windows.
Editing
- <DEL>
- Delete the character just typed (usually called Backspace on the keyboard).
- C-d
- Delete the next character after the cursor.
- M-<DEL>
- Kill the word immediately before the cursor.
- M-d
- Kill the next word after the cursor.
- C-k
- Kill from the cursor position to the end of the line. Multiple C-k's in a row will save the killed text together.
- M-k
- Kill to the end of the current sentence.
- C-<SPC>
- Start highlighting.
- C-w
- Kill text between the highlighted start and the cursor.
- M-w
- Copy text between the highlighted start and the cursor.
- C-u [n] [ch]
- Insert the character ch, n times.
- C-y
- Reinsert last killed text at the cursor.
- M-y
- Replace yanked text with the previous kill.
Undo
- C-/
- Undo changes made by one command. Repeat to undo more changes made by commands.
- C-x u
- Undo changes made by one command. Repeat to undo more changes made by commands.
Files
- C-x C-f
- Find a file.
- C-x C-s
- Save a file.
Buffers
- C-x C-b
- List buffers.
- C-x b [buff]
- Make buffer buff current.
- C-x s
- Save modified buffers (prompts you for each buffer).
Named Extended Commands
- M-x [cmd]
- Execute less-frequently used commands by name.
- M-x repl [s]
- Replace string s (prompts for the replacement).
Auto Save
- M-x recover-this-file
- Recovers the found autosave file.
Modes
- C-h m
- View documentation for your current major mode.
Auto Fill Minor Mode
- C-x f
- Change the autofill margin.
- M-q
- Re-fill the paragraph.
Searching
- C-s
- Initiate a forward search, or find the next occurrence.
- C-r
- Initiate a reverse search, or find the previous occurrence.
- <DEL>
- When already searching, retreats to the earlier locations.
- <Return>
- Terminate the search.
Multiple Windows and Frames
- C-x 2
- Split the screen horizontally into two windows.
- C-M-v
- Scroll the other window.
- C-x o
- Move the cursor to the other window.
- C-x 4 C-f
- Open file in the other window, and make the other window the active window.
- C-x 5 2
- Open a new frame (operating system window).
- C-x 5 0
- Remove the selected frame.
Recursive Editing Levels
- <ESC> <ESC> <ESC>
- Get out of a recursive editing level.
Help
- C-h [ch]
- Get help about topic ch (c - command, k - documentation, f - function, v - variables, a - apropos, r - read manual).
- C-h c [cmd]
- Get help about cmd. E.g. C-h c C-p to get help about moving to a previous line.