Leap within a line
0 ^ $ jump to the line ends; f and t jump straight to any character, and ; repeats.
12:03 p.m., day two. The lunch rush is on, and one rider has now circled the same block five times. Somewhere in delivery.ts an address is off by a single character, buried in a line longer than your screen.
Word hops would get you there eventually. But you can see the character you want. Why not ride straight to it?
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
The corner, the first house, the end of the street
Think of a line as a street with a house on every character. 0 takes you to the corner where the street begins, column zero. ^ skips the empty lots of indentation and stops at the first house: the first character that isn't a space. $ rides to the end of the street. In indented code, ^ is usually the one you want.
const fee = distanceKm > 5 ? 2.5 : 0;0^$Both ends
Some targets sit at the start or end of a line. 0, ^ and $ get there in one key.
This exercise needs a keyboard. Read on, and play it at your computer.
f rides to the house you can see
f plus a character rides you straight to the next house with that sign on it. f, rides to the next comma; f( to the next bracket. Look at where you want to be, name the character, and you're at its door.
assign(order, nearest, { rush: true }, eta, "bike");Ride to it
Each target sits on a character you can name. Ride there with f.
This exercise needs a keyboard. Read on, and play it at your computer.
Not on this street
You press fm. The only m is on the next line, in minutes. Where does the cursor go?
The circling rider
Here's the rider's stop, straight from delivery.ts: the street number has a digit too many, and the note is missing a letter. Ride to each one with f, then fix it with x or i.
This exercise needs a keyboard. Read on, and play it at your computer.
t pulls up one house short
t is f's careful twin: it rides till the character and pulls up one house before it. That's exactly where you want to be when you're about to type in front of a bracket, or delete up to it.
log(fmt(order.id), eta(nearest));log(fmt(order.id), eta(nearest));Just before
These targets sit right before a bracket, quote or comma. t pulls up there in two keys.
This exercise needs a keyboard. Read on, and play it at your computer.
The next house, or back again
Missed? Don't name the character again. ; rides on to the next house with the same sign, and , rides back the way you came. Four commas along is f, then ; ; ;: five keys, no counting, and you see each stop as you pass it.
notify(user.phone, order.id, rider.name, eta, "on its way");notify(user.phone, order.id, rider.name, eta, "on its way");Ride on
Each target is a few commas or brackets along. Ride once, then ; until you arrive; , if you overshoot.
This exercise needs a keyboard. Read on, and play it at your computer.
Overshot
Each ride starts one or two stops too far. Don't name the character again: , rides back the way you came.
This exercise needs a keyboard. Read on, and play it at your computer.
Till, then again
You press t,, then ;. Where does the cursor end up?
Capitals ride backwards
F and T turn around and ride back toward the corner: F( stops at the previous bracket, T( pulls up just after it. And ; keeps riding in whichever direction you set off.
Both directions
Targets on both sides of the cursor now. Pick your direction before you ride.
This exercise needs a keyboard. Read on, and play it at your computer.
if (!nearest || nearest.distance > MAX_DISTANCE_KM) {0^F(f>t)$Name the jump
No scrolling up. Read the situation, press the keys.
Address patrol
Dispatch wants every assignment in delivery.ts double-checked before the next wave of orders. Twelve stops, jumps getting longer. Rides, repeats, line ends: whatever gets you there in the fewest keys.
This exercise needs a keyboard. Read on, and play it at your computer.
The next wave
The second wave of lunch orders goes out at one, and dispatch wants the whole stops list right before it does. Four more addresses have a character too many or too few. Ride to each one, fix it, and nobody else circles a block today.
Stuck? Show a hint
f or t to the spot (; to ride on, , if you overshoot), then x for an extra character, i + the missing one + <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.
Dispatch never sleeps
Endless targets on fresh code, longer rides every level. Every find and repeat is allowed.
This exercise needs a keyboard. Read on, and play it at your computer.