Emacs is a powerful text editor with a steep learning curve, but once you get the hang of it, it can be highly efficient. Here’s a basic cheat sheet to help you navigate and perform common tasks in Emacs:
Basic Navigation
- Move Cursor:
- Forward:
C-f
(Ctrl + f) - Backward:
C-b
(Ctrl + b) - Up:
C-p
(Ctrl + p) - Down:
C-n
(Ctrl + n)
- Forward:
- Page Navigation:
- Next Page:
C-v
(Ctrl + v) - Previous Page:
M-v
(Alt + v)
- Next Page:
- Go to Beginning/End of Line:
- Beginning:
C-a
(Ctrl + a) - End:
C-e
(Ctrl + e)
- Beginning:
Editing
- Copy/Paste:
- Copy:
M-w
(Alt + w) - Cut:
C-w
(Ctrl + w) - Paste:
C-y
(Ctrl + y)
- Copy:
- Undo/Redo:
- Undo:
C-/
(Ctrl + /) orC-x u
- Redo:
M-/
(Alt + /) orC-x C-u
- Undo:
- Search/Replace:
- Search:
C-s
(Ctrl + s) - Replace:
M-x replace-string
- Search:
File Operations
- Open File:
C-x C-f
- Save File:
C-x C-s
- Close Emacs:
C-x C-c
Buffers and Windows
- Switch Buffer:
C-x b
- Split Windows:
- Horizontally:
C-x 2
- Vertically:
C-x 3
- Horizontally:
- Switch Between Windows:
- Next:
C-x o
(Ctrl + x, then o)
- Next:
Marking Text
- Set Mark:
C-SPC
(Ctrl + Space)
- Mark Region:
- Move cursor and set mark (
C-SPC
), then perform actions.
- Move cursor and set mark (
Advanced Commands
- Execute Command:
M-x
- Open/Close Dired (File Explorer):
C-x d
- Shell:
M-x shell
- Comment/Uncomment Region:
M-;
(Alt + 😉
Customization
- Init File (Configuration):
C-x C-f ~/.emacs.d/init.el
- Reload Configuration:
M-x load-file RET ~/.emacs.d/init.el
Help
- Get Help for a Command:
C-h k
followed by the key sequence.
- Info Pages:
C-h i
Exiting Emacs
- Save-buffers-kill-Emacs:
C-x C-c
Remember, these are just basic commands, and Emacs has a vast number of features and customization options. Explore the manual (C-h t
for the tutorial) and documentation for more in-depth information.