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

KeyEffect
i / aInsert before / after cursor
I / AInsert at start / end of line
o / OOpen new line below / above
vVisual (character)
VVisual (line)
Ctrl-vVisual (block)
:Command-line mode
EscBack to Normal mode, always

Moving around

KeyEffect
h j k lLeft, down, up, right
w / b / eNext word / back a word / end of word
0 / ^ / $Start of line / first non-blank / end of line
gg / GTop / bottom of file
12GGo to line 12
{ / }Previous / next paragraph
3j, 5w, etc.Repeat a motion N times

Editing

KeyEffect
xDelete character
ddDelete line
dwDelete to end of word
d$Delete to end of line
yyYank (copy) line
ywYank word
p / PPaste after / before cursor
u / Ctrl-rUndo / redo
.Repeat last change
cwChange word (delete + insert)
ccChange whole line

Search and replace

CommandEffect
/textSearch forward
?textSearch backward
n / NNext / previous match
:s/old/new/Replace first match on current line
:s/old/new/gReplace all matches on current line
:%s/old/new/gReplace all matches in the whole file
:%s/old/new/gcSame, but confirm each replacement

Registers and clipboard

CommandEffect
"ayyYank line into register a
"apPaste from register a
"+yyYank line into system clipboard
"+pPaste from system clipboard

Files and buffers

CommandEffect
:wSave
:qQuit
:q!Quit without saving
:wq / :xSave and quit
:e fileOpen a file
:lsList open buffers
:b 2Switch to buffer 2
:sp file / :vsp fileHorizontal / vertical split
Ctrl-w + directionMove between splits
:tabnew fileOpen file in a new tab
gt / gTNext / previous tab

When stuck

ActionEffect
EscBack to Normal mode from anywhere
:help topicBuilt-in help
:q!Escape hatch out of a file entirely

← Building a Habit