Emacs command cheatsheet
M means the Esc or Alt Key
– in Ctrl-x means press Ctrl and then x
1. Emacs File Control
emacs Hello.java Open or create the file “Hello.java” with emacs on command line.
Ctrl-x Ctrl-s Save changes.
Ctrl-x Ctrl-f Open a new file.
Ctrl-x b Switch back to previous file or type a file you want to switch to.
Ctrl-x Ctrl-b gives a list of opened files.
Ctrl-x d Enter the dried mode. Type the Capital R to rename the file. Ctrl-x b Go back to the file.
Ctrl-g Quit the current operation.
Ctrl+z Quit emacs.
2. Emacs Line Control
Ctrl-a Move the cursor to the beginning of the current line.
Ctrl-e Move the cursor to the end of the current line.
M-a Move back to the beginning of sentence.
M-e Move forward to the end of sentence.
M-g g or M-g M-g To go to a specific line.
Ctrl-k Delete the line from current point, or in emacs language it kill the line.
Ctrl-a Ctrl-kDelete the whole line.
3. Emacs Cursor Control
Ctrl-f Move forward one character.
Ctrl-b Move backward one character.
Ctrl-n Move the cursor to the next line.
Ctrl-p Move the cursor to the previous line.
4. Emacs Screen Control
Ctrl-v Scroll the file forward by one screen.
M-v Scroll the file backward by one screen.
M-< Go to the beginnig of the file. Remember > needs to have the Shift key.
M-> Go to the end of the file.
Ctrl-x 1 Delete other windows
Ctrl-x 2 Split windows vertically
5. Emacs Search and Replace
Ctrl-s Search forward. Type the below command and then the string to search. To search for the next occurance of the same string, type the below command again.
Ctrl-r Search backward.
M-%Search replace, press Alt Shift and %, then type the search string and enter, then type the replacement string and enter, then press y to do the replacement, n to skip, ! to do all remaining replacements without asking, q to exit.
6. Emacs Copy and Paste
Ctrl-Space or Ctrl-@ To select a region of text.
Ctrl-w To cut the text. Cutting is called killing in emacs.
M-w To copy the text.
Ctrl-y to paste the text. Pasting is called yanking in emacs.
7. Emacs Undo and Redo
Ctrl-_ or Ctrl-/ or Ctrl-x u Undo, when there is no more left to undo. To redo, Ctrl-x and then the same command as the undo.
8. Emacs Help
Ctrl-h Help command.
Ctrl-h t Help with tutorial.
Search within Codexpedia
Search the entire web