Move without the mouse
h j k l keep your fingers on the home row. Counts like 5j multiply any motion, the gutter tells you the count, and you walk the kitchen file to fix a ticket that prints twice.
10:20 a.m. The next ticket says a kitchen ticket prints twice, and the bug is somewhere in kitchen.ts, a dozen lines down. The mouse is in the drawer. Your right hand starts drifting toward the arrow keys, a trip to the far corner of the keyboard and back every time you want to move.
Stop it halfway. Everything you need is already under your fingers, on the home row where they live.
Warm-up from earlier chapters
One from an earlier chapter, from memory, before the new idea. Two wrong tries show the answer.
Four keys, no trip
In Normal mode, four keys under your right hand move the cursor, so you never leave home: h left, j down, k up, l right. The shapes help: j has a hook that hangs down, k is the tall one that reaches up, and h and l sit on the left and right ends.
const tip = order.total * 0.15;const pay = order.total + tip;await charge(user, pay);const tip = order.total * 0.15;const pay = order.total + tip;await charge(user, pay);const tip = order.total * 0.15;const pay = order.total + tip;await charge(user, pay);const tip = order.total * 0.15;const pay = order.total + tip;await charge(user, pay);First steps
Walk onto each green square with h j k l. They start close.
This exercise needs a keyboard. Read on, and play it at your computer.
Counts multiply
Put a number in front of a motion and Vim repeats it: 5j is five steps down in one breath, and 3l is three to the right. Two keys instead of five, and no counting presses while you go.
The gutter is a ruler
Look at the line numbers beside the code: they work like a ruler laid along the file. Your line shows its real number; every other line shows how far away it is. The line you want says 4? Press 4j. You never count lines yourself; you read the number off the gutter.
Off by one?
The cursor is on startNext(). You press 4j. Which line does it land on?
Count, then move
Read the distance off the gutter and jump in one go: 3j instead of j j j. Par assumes you use counts.
This exercise needs a keyboard. Read on, and play it at your computer.
Which way?
Read the situation, press the keys.
Menu walk
The menu is being reprinted and every line needs a look before it goes out. Twelve stops across menu.ts, getting further apart as you go. Counts welcome.
This exercise needs a keyboard. Read on, and play it at your computer.
Kitchen tickets
The double print is in this file. Follow an order through kitchen.ts the way the kitchen does, stop by stop, and you'll walk straight into it: two printTicket lines, one after the other. Then fix it: at the start of the second one, type two slashes and a space (// then a space). Two slashes turn a line into a comment, a note the computer skips.
On the way you'll lose your place a few times, on purpose. The gutter says how far back.
Stuck? Show a hint
Read the gutter, then one count: 4j, 9k, 14j… On the second printTicket line: i// <Esc>This exercise needs a keyboard. Read on, and play it at your computer.
Extra practice optional
The chapter is done. These rounds keep going as long as you like: stop whenever it stops being useful.
Keep walking
Endless targets on fresh code every ten goals, a little further each level. Stop whenever you like.
This exercise needs a keyboard. Read on, and play it at your computer.