GNU Emacs keyboard shortcuts
GNU Emacs uses Control and Meta key notation for movement, editing, files, buffers, windows, search, help, and keyboard macros. Prefix commands are shown in press order rather than as one chord.
Windows, macOS, Linux · 62 shortcutsMovement
These default editing commands move by character, word, line, sentence, screen, or buffer.
| Action | Windows | macOS | Linux |
|---|---|---|---|
| Move forward one character | CtrlF | CtrlF | CtrlF |
| Move backward one character | CtrlB | CtrlB | CtrlB |
| Move to the next line | CtrlN | CtrlN | CtrlN |
| Move to the previous line | CtrlP | CtrlP | CtrlP |
| Move to the beginning of the line | CtrlA | CtrlA | CtrlA |
| Move to the end of the line | CtrlE | CtrlE | CtrlE |
| Move forward one word | AltF | OptionF | AltF |
| Move backward one word | AltB | OptionB | AltB |
| Move to the previous sentence | AltA | OptionA | AltA |
| Move to the next sentence | AltE | OptionE | AltE |
| Scroll forward one screen | CtrlV | CtrlV | CtrlV |
| Scroll backward one screen | AltV | OptionV | AltV |
| Move to the beginning of the buffer | Alt< | Option< | Alt< |
| Move to the end of the buffer | Alt> | Option> | Alt> |
| Go to a line | AltGthenG | OptionGthenG | AltGthenG |
Editing and regions
Kill commands remove text into the kill ring, while yank commands put it back.
| Action | Windows | macOS | Linux |
|---|---|---|---|
| Delete the character at point | CtrlD | CtrlD | CtrlD |
| Delete the character before pointGNU documents this as DEL, which is commonly the Backspace key on a modern keyboard. | DEL | DEL | DEL |
| Kill to the end of the line | CtrlK | CtrlK | CtrlK |
| Kill the next word | AltD | OptionD | AltD |
| Kill the previous word | AltBackspace | OptionBackspace | AltBackspace |
| Kill the active region | CtrlW | CtrlW | CtrlW |
| Copy the active region to the kill ring | AltW | OptionW | AltW |
| Yank the most recent kill | CtrlY | CtrlY | CtrlY |
| Replace the last yank with the previous kill | AltY | OptionY | AltY |
| Set the mark | CtrlSpace | CtrlSpace | CtrlSpace |
| Exchange point and mark | CtrlXthenCtrlX | CtrlXthenCtrlX | CtrlXthenCtrlX |
| Mark the entire buffer | CtrlXthenH | CtrlXthenH | CtrlXthenH |
| Undo | Ctrl_ | Ctrl_ | Ctrl_ |
| Quit the current command | CtrlG | CtrlG | CtrlG |
Files
File commands visit, save, write, revert, and close buffers in the current Emacs session.
| Action | Windows | macOS | Linux |
|---|---|---|---|
| Visit a file | CtrlXthenCtrlF | CtrlXthenCtrlF | CtrlXthenCtrlF |
| Visit a file read-only | CtrlXthenCtrlR | CtrlXthenCtrlR | CtrlXthenCtrlR |
| Visit a different file in the current buffer | CtrlXthenCtrlV | CtrlXthenCtrlV | CtrlXthenCtrlV |
| Visit a file in another window | CtrlXthen4thenF | CtrlXthen4thenF | CtrlXthen4thenF |
| Visit a file in another frame | CtrlXthen5thenF | CtrlXthen5thenF | CtrlXthen5thenF |
| Save the current buffer | CtrlXthenCtrlS | CtrlXthenCtrlS | CtrlXthenCtrlS |
| Write the buffer to a new file | CtrlXthenCtrlW | CtrlXthenCtrlW | CtrlXthenCtrlW |
| Save some modified buffers | CtrlXthenS | CtrlXthenS | CtrlXthenS |
| Execute a named command | AltX | OptionX | AltX |
| Quit Emacs | CtrlXthenCtrlC | CtrlXthenCtrlC | CtrlXthenCtrlC |
Buffers and windows
Switch buffers, split or remove windows, and move between windows with these prefix commands.
| Action | Windows | macOS | Linux |
|---|---|---|---|
| Switch to a buffer | CtrlXthenB | CtrlXthenB | CtrlXthenB |
| Switch to a buffer in another window | CtrlXthen4thenB | CtrlXthen4thenB | CtrlXthen4thenB |
| Switch to a buffer in another frame | CtrlXthen5thenB | CtrlXthen5thenB | CtrlXthen5thenB |
| Kill a buffer | CtrlXthenK | CtrlXthenK | CtrlXthenK |
| Remove the selected window | CtrlXthen0 | CtrlXthen0 | CtrlXthen0 |
| Make the selected window the only window | CtrlXthen1 | CtrlXthen1 | CtrlXthen1 |
| Split the selected window horizontally | CtrlXthen2 | CtrlXthen2 | CtrlXthen2 |
| Split the selected window vertically | CtrlXthen3 | CtrlXthen3 | CtrlXthen3 |
| Move to another window | CtrlXthenO | CtrlXthenO | CtrlXthenO |
Search and replacement
Incremental search starts matching as text is entered. Query replacement asks how to handle each match.
| Action | Windows | macOS | Linux |
|---|---|---|---|
| Search forward incrementally | CtrlS | CtrlS | CtrlS |
| Search backward incrementally | CtrlR | CtrlR | CtrlR |
| Search forward with a regular expression | CtrlAltS | CtrlOptionS | CtrlAltS |
| Query and replace text | Alt% | Option% | Alt% |
Help
The Control-H prefix opens Emacs's built-in command and manual help.
| Action | Windows | macOS | Linux |
|---|---|---|---|
| Show active key bindings | CtrlHthenB | CtrlHthenB | CtrlHthenB |
| Show the command bound to a key | CtrlHthenC | CtrlHthenC | CtrlHthenC |
| Show documentation for a key | CtrlHthenK | CtrlHthenK | CtrlHthenK |
| Show documentation for a function | CtrlHthenF | CtrlHthenF | CtrlHthenF |
| Search for commands by topic | CtrlHthenA | CtrlHthenA | CtrlHthenA |
| Open the Emacs manual | CtrlHthenR | CtrlHthenR | CtrlHthenR |
| Open the Emacs tutorial | CtrlHthenT | CtrlHthenT | CtrlHthenT |
Keyboard macros
Record a sequence of keystrokes and replay it from the keyboard macro commands.
| Action | Windows | macOS | Linux |
|---|---|---|---|
| Start recording a keyboard macro | CtrlXthen( | CtrlXthen( | CtrlXthen( |
| Stop recording a keyboard macro | CtrlXthen) | CtrlXthen) | CtrlXthen) |
| Run the last keyboard macro | CtrlXthenE | CtrlXthenE | CtrlXthenE |