Vim Scoops / Lessons / Cheat sheet

Vim cheat sheet

Every essential Vim command on one page. Linked ones have a lesson with a game to practise on. Print it, or save it as a wallpaper so it's always behind your editor.

The commands

Save and quit

:wSave
:qQuit
:q!Quit without saving
:wq :x ZZSave and quit
ZQQuit without saving
:wa :qaSave / quit every file

Move

h j k lLeft, down, up, right
w b eNext word, back, word end
W B ESame, by spaces only
0 ^ $Line start, first char, end
gg GFirst / last line
:42 42GGo to line 42
fx FxJump to x, forward / back
tx TxStop just before / after x
; ,Repeat the jump, same / other way
%Matching bracket
{ }Previous / next paragraph
Ctrl-D Ctrl-UHalf a page down / up
5jAny move with a count

Insert

i aType before / after the cursor
I AType at line start / end
o ONew line below / above
EscBack to Normal mode

Edit

xDelete a character
dd 3ddDelete a line / three lines
DDelete to end of line
dw dawDelete a word
cc CChange the line / to its end
ciwChange a word
ci" ci(Change inside quotes / brackets
rReplace one character
JJoin the next line on
~Flip case
>> <<Indent / outdent

Copy and paste

yyCopy a line
yw y$Copy a word / to line end
p PPaste below / above
"+y "+pSystem clipboard copy / paste
"ayy "apCopy into / paste from register a

Undo and repeat

uUndo
Ctrl-RRedo
.Repeat the last change
:earlier 5mWind back five minutes

Select

vSelect characters
VSelect lines
Ctrl-VSelect a block
oOther end of the selection
gvReselect the last selection
ggVGSelect everything

Search and replace

/word ?wordSearch forward / back
n NNext / previous match
*Search the word under the cursor
:%s/old/new/gReplace in the whole file
:%s/old/new/gcReplace, asking each time
:nohClear the highlighting

Macros

qa … qRecord into register a
@a @@Play it / play the last again
10@aPlay it ten times

Files and windows

:e fileOpen a file
:sp :vspSplit the window: stacked / side by side
Ctrl-W wNext window
:bn :bpNext / previous buffer

Get it as a wallpaper

The essentials, in Vim Scoops colours, dark or light, sized for your screen.

Get the wallpapers

Try it

Drive the van onto the customer with h j k l.

Want all of Vim, in order? Vim Scoops is a free game that starts at h j k l and builds up to macros.

Play the full game