For over four decades, Emacs has stood as a pillar in the text editing world, beloved by programmers, writers, and power users alike. What makes Emacs particularly powerful is its extensive keyboard shortcut system that allows users to perform complex operations without ever touching the mouse.
Emacs comes with an excellent built-in tutorial that can be accessed with C-h t
(Control-h followed by t). I highly recommend all new users complete this tutorial to get comfortable with Emacs’ fundamentals. That said, the tutorial is comprehensive and takes time to complete.
This guide serves as a TL;DR and quick reference of the most essential hotkeys you should memorize. Consider it a short recap of what’s worth knowing by heart to be immediately productive in Emacs, whether you’re new to the editor or just need a refresher.
Understanding Emacs Notation
Before diving into the hotkeys themselves, let’s decode how to read Emacs key notation:
- C- represents the Control key. For example,
C-a
means “hold Control and press a”. - M- represents the Meta key, which on modern keyboards is typically the Alt key. So
M-f
means “hold Alt and press f”. - C-x followed by another key represents a two-key sequence. Press Control and x together, release, then press the next key.
- M-x similarly starts a command sequence where you type the command name after pressing Alt and x.
Multiple modifier keys can be combined. For example, C-M-f
means holding both Control and Alt while pressing f.
With this foundation, let’s explore the essential hotkeys that will dramatically improve your Emacs efficiency.
Essential Emacs Hotkeys by Category
Text Navigation
Efficient text navigation is the foundation of productive editing. These shortcuts let you move through your document with precision:
Hotkey | Action Description |
---|---|
C-a | Move to beginning of line |
C-e | Move to end of line |
C-f | Move forward one character |
C-b | Move backward one character |
M-f | Move forward one word |
M-b | Move backward one word |
C-n | Move to next line |
C-p | Move to previous line |
C-v | Page down |
M-v | Page up |
M-< | Move to beginning of buffer |
M-> | Move to end of buffer |
C-l | Recenter buffer around cursor |
The navigation keys follow a pattern: f
for forward, b
for backward, p
for previous, and n
for next. Once you internalize these patterns, they become second nature.
Text Editing
These shortcuts handle the core editing operations that you’ll use hundreds of times daily:
Hotkey | Action Description |
---|---|
C-d | Delete character at point |
M-<backspace> | Delete word backward |
M-d | Delete word forward |
C-k | Kill (cut) from cursor to end of line |
C-w | Kill (cut) selected region |
M-w | Copy selected region |
C-y | Yank (paste) most recently killed text |
M-y | Cycle through kill ring after yanking |
C-/ or C-_ | Undo |
A unique aspect of Emacs is its “kill ring” - a clipboard system that remembers multiple deleted items. After using C-y
to paste the most recent item, you can press M-y
repeatedly to cycle through previously killed text.
Region and Selection
Working with selections in Emacs involves understanding the concept of the “mark” and “point”:
Hotkey | Action Description |
---|---|
C-space | Set mark (start selection) |
C-x C-x | Exchange point and mark (swap selection endpoints) |
C-x h | Select entire buffer |
The mark is where a selection begins, and the point is your cursor position. Together they define the “region” - Emacs’ term for a selection.
File Operations
These commands handle file management tasks:
Hotkey | Action Description |
---|---|
C-x C-f | Find (open) file |
C-x C-s | Save current buffer |
C-x s | Save all buffers |
C-x C-c | Exit Emacs |
C-x d | Open directory (dired) |
The C-x C-f
command is particularly powerful as it allows you to create new files by entering paths that don’t exist yet.
Buffer Management
In Emacs, a buffer is essentially an open file or space for editing:
Hotkey | Action Description |
---|---|
C-x b | Switch buffer |
C-x k | Kill (close) buffer |
Efficient buffer navigation is crucial when working with multiple files.
Window Management
Emacs allows for sophisticated window layouts:
Hotkey | Action Description |
---|---|
C-x 2 | Split window horizontally (one above the other) |
C-x 3 | Split window vertically (side by side) |
C-x o | Switch to other window |
C-x 0 | Close current window |
C-x 1 | Close all windows except current |
C-x 5 2 | Create new frame (GUI window) |
The ability to split the editor into multiple windows, each showing different buffers, is one of Emacs’ most powerful features.
Search and Replace
Finding and replacing text efficiently is essential for editing:
Hotkey | Action Description |
---|---|
C-s | Incremental search forward |
C-r | Incremental search backward |
M-% | Query replace |
Emacs’ incremental search updates as you type, making it quick to locate specific text.
Help System
When you inevitably need guidance, Emacs has built-in help:
Hotkey | Action Description |
---|---|
C-h f | Describe function |
C-h k | Describe key |
C-h t | Start tutorial |
The self-documenting nature of Emacs means help is always just a few keystrokes away.
Macros
Macros are powerful tools for automating repetitive tasks:
Hotkey | Action Description |
---|---|
F3 | Start recording a keyboard macro |
F4 | Stop recording or execute the most recent keyboard macro |
To use macros: press F3, perform the sequence of actions you want to repeat, press F4 to finish recording, then press F4 again each time you want to replay those exact keystrokes. This is incredibly useful for mass operations on text.
Command Execution
Finally, the gateway to thousands of Emacs commands:
Hotkey | Action Description |
---|---|
M-x | Execute command by name |
This shortcut unlocks Emacs’ full potential, giving you access to any command by name.
Building Your Muscle Memory
Learning these hotkeys will take time, but the productivity payoff is immense. Start by mastering the navigation and basic editing commands, then gradually incorporate the others. Consider printing this list and keeping it near your workspace until the keystrokes become automatic.
Remember that Emacs is highly customizable - once you’re comfortable with these basics, you can create your own keybindings for commands you use frequently.
Conclusion
The beauty of Emacs lies in how it becomes an extension of your thinking process once you’ve internalized these commands. Text manipulation becomes effortless, allowing you to focus on your actual work rather than the mechanics of editing.
While this guide covers the essential hotkeys, it barely scratches the surface of what Emacs can do. As you grow more comfortable with these basics, explore specialized modes for your particular work, whether that’s programming in specific languages, writing prose, managing projects, or organizing your life.
What began as a seemingly steep learning curve will transform into a powerful skillset that follows you throughout your computing life. Happy editing!