Emacs Keyboard Shortcuts

Become an Emacs guru with this cheatsheet.

Emacs Keybindings 00 Featured Image

Emacs is a fully-featured text editor that is both powerful and extensible out of the box, without needing to install any additional packages to make it work. With Emacs, you can easily manipulate text and files by executing Lisp commands. These commands, in turn, are then bound to a series of simple keybindings which allows you to focus on what you need to do.

Emacs Keyboard Shortcuts Download

Download this Cheatsheet

Enter your email below to receive this PDF cheatsheet in your Inbox.

Essential Emacs Keyboard Shortcuts

By default, Emacs already comes with a good number of shortcuts that you can use to do basic text editing, buffer manipulation and shell code execution. However, one issue with the default keyboard shortcuts for Emacs is that information about them are often either scant or obscure.

Knowing that, this cheatsheet aims to bridge that gap by highlighting some of Emacs’ most useful features. Further, this also includes how you can access them through simple keyboard shortcuts.

ShortcutFunction
General Emacs Controls
Ctrl + GCancel or suspend a command.
Ctrl + G, then Ctrl + G, then Ctrl + GForcibly suspend a command.
Ctrl + LRefresh the current screen.
Alt + X, then “recover session”Restore any unsaved buffers.
Ctrl + X, then Ctrl + CSave all buffers and close Emacs.
Alt + X, then “customize”Open the built-in customization menu.
File Manipulation
Ctrl + X, then Ctrl + FOpen a File Buffer.
Ctrl + X, then Ctrl + SSave the current file in the buffer.
Ctrl + X, then SSave all files in buffer.
Ctrl + X, then Ctrl + DOpen a Dired Buffer.
Ctrl + X, then Ctrl + WWrite the current file to a different buffer.
Ctrl + X, then Ctrl + QTurn the current buffer to Read-Only.
Text Selection
Alt + H Select the paragraph before the cursor.
Ctrl + Alt + HSelect the function before the cursor.
Ctrl + X, then Ctrl + PSelect everything in the current screen.
Ctrl + HSelect the entire buffer.
Ctrl + SpaceActivate the region select tool.
Text Manipulation
Ctrl + WCut the text within the selected region.
Ctrl + DCut the character after the
Ctrl + KCut the entire line after the cursor.
Alt + KCut the entire sentence after the cursor.
Alt + U Convert the word before the cursor to uppercase.
Ctrl + X, then Ctrl + UConvert the selected region to uppercase.
Alt + LConvert the word before the cursor to lowercase.
Ctrl + X, then Ctrl + LConvert the selected region to lowercase.
Ctrl + TSwitch the two adjacent letters before the cursor.
Alt + TSwitch the two adjacent words before the cursor.
Text Formatting
Ctrl + OAdd a new line above the cursor.
Ctrl + X, then Ctrl + O Remove any empty lines around the cursor.
Alt + \Remove all spaces around the cursor.
Alt + QTruncate the paragraph to the current column length.
Ctrl + X, FSet the current column length.
Searching and Replacing
Ctrl + SSearch for text after the cursor.
Ctrl + RSearch for text before the cursor.
Alt + PUse the previously searched text for searching.
Ctrl + Alt + S Search for text after the cursor using regex.
Ctrl + Alt + R Search for text before the cursor using regex.
M + %Enter Emacs’ Interactive Replace menu.
Buffer Movement
Ctrl + FMove the cursor one character forward.
Ctrl + BMove the cursor one character backward.
Alt + FMove the cursor one word forward.
Alt + BMove the cursor one word backward.
Ctrl + NMove the cursor one line down.
Ctrl + PMove the cursor one line up.
Ctrl + VScroll the entire buffer screen down.
Alt + VScroll the entire buffer screen up.
Ctrl + EMove the cursor to the end of the current line.
Ctrl + AMove the cursor to the start of the current line.
Alt + EMove the cursor to the end of the current sentence.
Alt + AMove the cursor to the start of the current sentence.
Buffer Manipulation
Ctrl + X, then 2Split the current buffer horizontally.
Ctrl + X, then 3Split the current buffer vertically.
Ctrl + X, then 4, then BOpen an existing buffer as a vertical split.
Ctrl + X, then 4, then FOpen a file as a vertical split.
Ctrl + X, then 4, then DOpen directory as a vertical split.
Ctrl + X, then 1Delete all other splits aside from the currently selected one.
Ctrl + X, then 0Delete the currently selected split.
Ctrl + X, then BSwitch to a different buffer.
Ctrl + X, then Ctrl + BPrint a list of all existing buffers.
Command Buffer Controls
?Suggest potential completion options.
Alt + PRewrite the previous command in the buffer.
Alt + RSearch backwards through the command buffer history.
Alt + FSearch forwards through the command buffer history.
Shell Support
Alt + X, then “term”Open a VT100 Terminal Emulator.
Alt + X, then “eshell”Open an Emacs Lisp Terminal.
Alt + !Run a shell command from the command buffer.
Alt + &Run a shell command and fork the process to the background.
Keyboard Macros
Ctrl + X, then (Create an Emacs keyboard macro.
Ctrl + X, then )Save an Emacs keyboard macro.
Ctrl + X, then ERun the last Emacs macro defined.
Lisp-specific Functions
Ctrl + X, then Ctrl + ERun the currently selected Lisp expression.
Ctrl + Alt + XRun the currently selected a Lisp function.
Emacs Help System
Ctrl + H, then ?Open a summary of all the options for the Help system.
Ctrl + H, then ASearch for a specific Help topic.
Ctrl + H, then FOpen a Help window about the highlighted Lisp function.
Ctrl + H, then VOpen a Help window about the highlighted Lisp variable.
Ctrl + H, then MOpen a Help window for the current Major Mode.
Ctrl + H, then PSearch for an installed Emacs package.
Ctrl + H, then Shift + PSearch for the documentation of an Emacs package.
Ctrl + H, then IOpen the Emacs Info Screen.
Ctrl + H, then Ctrl + FOpen the Emacs FAQ.
Ctrl + H, then Ctrl + NView the most recent news about Emacs.
Emacs Info Screen
HOpen the Info Screen tutorial.
SpaceScroll down the currently displayed text by half a screen.
BackspaceScroll up the currently displayed text by half a screen.
NGo to the next Info node for the document.
PGo to the previous Info node for the document.
TGo to the top Info node for the document.
DGo to the document’s Table of Contents.
LGo back to the last Info node that you read.
QExit Emacs’ Info Screen Mode.

Image credit: Unsplash

Ramces Red
Ramces Red

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox