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
:w | Save |
:q | Quit |
:q! | Quit without saving |
:wq :x ZZ | Save and quit |
ZQ | Quit without saving |
:wa :qa | Save / quit every file |
Move
h j k l | Left, down, up, right |
w b e | Next word, back, word end |
W B E | Same, by spaces only |
0 ^ $ | Line start, first char, end |
gg G | First / last line |
:42 42G | Go to line 42 |
fx Fx | Jump to x, forward / back |
tx Tx | Stop just before / after x |
; , | Repeat the jump, same / other way |
% | Matching bracket |
{ } | Previous / next paragraph |
Ctrl-D Ctrl-U | Half a page down / up |
5j | Any move with a count |
Insert
i a | Type before / after the cursor |
I A | Type at line start / end |
o O | New line below / above |
Esc | Back to Normal mode |
Edit
x | Delete a character |
dd 3dd | Delete a line / three lines |
D | Delete to end of line |
dw daw | Delete a word |
cc C | Change the line / to its end |
ciw | Change a word |
ci" ci( | Change inside quotes / brackets |
r | Replace one character |
J | Join the next line on |
~ | Flip case |
>> << | Indent / outdent |
Copy and paste
yy | Copy a line |
yw y$ | Copy a word / to line end |
p P | Paste below / above |
"+y "+p | System clipboard copy / paste |
"ayy "ap | Copy into / paste from register a |
Undo and repeat
u | Undo |
Ctrl-R | Redo |
. | Repeat the last change |
:earlier 5m | Wind back five minutes |
Select
v | Select characters |
V | Select lines |
Ctrl-V | Select a block |
o | Other end of the selection |
gv | Reselect the last selection |
ggVG | Select everything |
Search and replace
/word ?word | Search forward / back |
n N | Next / previous match |
* | Search the word under the cursor |
:%s/old/new/g | Replace in the whole file |
:%s/old/new/gc | Replace, asking each time |
:noh | Clear the highlighting |
Macros
qa … q | Record into register a |
@a @@ | Play it / play the last again |
10@a | Play it ten times |
Files and windows
:e file | Open a file |
:sp :vsp | Split the window: stacked / side by side |
Ctrl-W w | Next window |
:bn :bp | Next / previous buffer |
Get it as a wallpaper
The essentials, in Vim Scoops colours, dark or light, sized for your screen.
Get the wallpapersTry 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