Vim · game

Vim trainer game: hit the targets with hjkl and x in 30 seconds

A small code buffer, a cursor and a clock. Targets light up, you move with the real Vim keys and delete each one with x. Arrow keys score nothing, so your fingers learn the home row.

Arcade joystick and glowing buttons in a dark game room (AI-generated image)
AI-generated image

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.

-- NORMAL --time 30sscore 0best 0

  
Press Enter or Start, then hit the highlighted character with x.

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.
  • Esc pauses the round, and a second Esc resumes it.
  • :q ends the round, and so do :q!, :wq and :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:

KeyMovement in Vim
h / lOne character left / right
j / kOne line down / up
w / bNext word start / back to a word start
0 / $First column / last character of the line
gg / GFirst / last line of the buffer
xDelete 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:

  1. Days 1 and 2: only h j k l and x, aiming for zero arrow-key presses rather than a score.
  2. Days 3 and 4: add w, b, 0 and $.
  3. Days 5 to 7: every key, including gg and G, 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.

Last stops · FAQ

Questions people ask

Why does Vim use hjkl instead of the arrow keys?

Bill Joy wrote vi at the University of California, Berkeley, on a Lear Siegler ADM-3A, a terminal introduced in 1976. That keyboard had no separate arrow keys. The arrows were printed on H, J, K and L, because with Ctrl those keys sent the codes that moved the terminal's cursor. vi used the same letters for movement, and Vim kept them.

Does the Vim trainer work on a phone?

Partly. Below the buffer the game has tap buttons for h, j, k, l, w, b, 0, $ and x, and tapping one starts a round, so it can be played on a touch screen. gg, G, Esc and :q have no button and need a real keyboard. Tapping also skips the real lesson, which is in the fingers on the home row.

What is the difference between x and dl in Vim?

In real Vim, x is a short form of dl: delete the character under the cursor. The deleted character goes into the unnamed register, so p pastes it back after the cursor, which makes xp a quick way to swap two letters. A count works too: 3x deletes three characters, the same as d3l.

Next stop

Where this line continues