Appendix: Cheat Sheet
Everything from this book, on one page. Not a teaching document, this is
what you skim once you already know why each command exists.
Modes
| Key | Effect |
|---|
i / a | Insert before / after cursor |
I / A | Insert at start / end of line |
o / O | Open new line below / above |
v | Visual (character) |
V | Visual (line) |
Ctrl-v | Visual (block) |
: | Command-line mode |
Esc | Back to Normal mode, always |
Moving around
| Key | Effect |
|---|
h j k l | Left, down, up, right |
w / b / e | Next word / back a word / end of word |
0 / ^ / $ | Start of line / first non-blank / end of line |
gg / G | Top / bottom of file |
12G | Go to line 12 |
{ / } | Previous / next paragraph |
3j, 5w, etc. | Repeat a motion N times |
Editing
| Key | Effect |
|---|
x | Delete character |
dd | Delete line |
dw | Delete to end of word |
d$ | Delete to end of line |
yy | Yank (copy) line |
yw | Yank word |
p / P | Paste after / before cursor |
u / Ctrl-r | Undo / redo |
. | Repeat last change |
cw | Change word (delete + insert) |
cc | Change whole line |
Search and replace
| Command | Effect |
|---|
/text | Search forward |
?text | Search backward |
n / N | Next / previous match |
:s/old/new/ | Replace first match on current line |
:s/old/new/g | Replace all matches on current line |
:%s/old/new/g | Replace all matches in the whole file |
:%s/old/new/gc | Same, but confirm each replacement |
Registers and clipboard
| Command | Effect |
|---|
"ayy | Yank line into register a |
"ap | Paste from register a |
"+yy | Yank line into system clipboard |
"+p | Paste from system clipboard |
Files and buffers
| Command | Effect |
|---|
:w | Save |
:q | Quit |
:q! | Quit without saving |
:wq / :x | Save and quit |
:e file | Open a file |
:ls | List open buffers |
:b 2 | Switch to buffer 2 |
:sp file / :vsp file | Horizontal / vertical split |
Ctrl-w + direction | Move between splits |
:tabnew file | Open file in a new tab |
gt / gT | Next / previous tab |
When stuck
| Action | Effect |
|---|
Esc | Back to Normal mode from anywhere |
:help topic | Built-in help |
:q! | Escape hatch out of a file entirely |