Reading about Vim motions does little for your fingers. This Vim trainer gives you 30 seconds, ten lines of C and a cursor, and counts how many marked characters you reach and delete with real Vim keys.
How to play the Vim trainer
Press Enter or Start. One character turns orange; move onto it and press x, and a new target appears more than six steps away. The score is the number of hits when the clock runs out, and your browser keeps the best one.
- Only Vim keys move the cursor. Arrow keys print a reminder and do nothing else.
Escpauses the round, and a secondEscresumes it.:qends the round, and so do:q!,:wqand:x, the same commands that quit real Vim.
A target at the end of a line is one $ away, so picking the right motion scores better than tapping l fast.
What each key does in real Vim
Each key does what it does in Vim's normal mode:
| Key | Movement in Vim |
|---|---|
h / l | One character left / right |
j / k | One line down / up |
w / b | Next word start / back to a word start |
0 / $ | First column / last character of the line |
gg / G | First / last line of the buffer |
x | Delete the character under the cursor |
The trainer copies one detail of w from Vim: punctuation counts as a word of its own. On foo.bar baz, w stops at the dot, while Vim's capital W (not in the game) jumps to baz. And 0 means column one even on an indented line; in Vim, ^ goes to the first non-blank character instead.
Counts are missing from the game; in Vim, 5j moves five lines down.
Why hjkl sits on the home row
Vim's user manual explains the choice in section 02.3: moving the cursor is the most common thing you do in an editor, and these keys "are on the home row of your right hand". Reaching for the arrows means moving the whole hand, possibly hundreds of times an hour. The manual also offers a memory aid: h is on the left, l on the right, and j points down. vimtutor says j "looks like a down arrow".
A practice plan for one week
Three rounds a day:
- Days 1 and 2: only
h j k landx, aiming for zero arrow-key presses rather than a score. - Days 3 and 4: add
w,b,0and$. - Days 5 to 7: every key, including
ggandG, and note the best score.
Between rounds, move around a harmless file in vim without the arrows and leave with :q!; the Vim guide lists the other ways out. vimtutor covers the same movements plus editing.
Where the game stops
The trainer covers movement and one delete in a ten-line buffer. In a file of a few hundred lines, / and a few letters of the target usually beat any chain of j and w, and knowing when to stop moving and search instead is the one habit no round of this game can build.
