Undo chunks & counted arithmetic
u and Ctrl-r skip back and forward a whole change at a time. Ctrl-a and Ctrl-x click numbers up and down like a tally counter, and gCtrl-a numbers a column.
4:53 p.m. The order form is open, and every quantity on it is off by a few. From the next room comes the steady tap-tap-tap of someone holding down u, watching an hour of work disappear one chapter at a time.
Two things to learn before six: how far back u really goes, and how to change a number without retyping it.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
Undo skips whole chapters
On the remote, u doesn't rewind frame by frame: it skips back a whole chapter. Each change is one chapter, and everything you type between i and Esc is a single chapter, however long it was. Three short inserts are three chapters; one long one is one.
Skip forward again
Skipped back too far? Ctrl-r skips forward a chapter: redo. (Last lesson paired u with .; on the remote, u's real mirror is Ctrl-r.) It only replays chapters you skipped back over: make a new change and the chapters ahead are out of its reach. (Moving around is safe; only a change does this.) That's the danger in the next room: one stray edit and that hour is beyond Ctrl-r.
Back and forth
Three steps, one file. Delete the two stray letters with x. Then undo the last deletion with u, and redo it with Ctrl-r.
This exercise needs a keyboard. Read on, and play it at your computer.
A tally counter
That's undo done. Now the quantities. Ctrl-a is a tally counter, like the clicker at the door that counts people in and out: each press clicks the number up by one, and Ctrl-x clicks it down. A count clicks several times at once, so 5Ctrl-a adds five. No deleting digits, no typing, and no off-by-one.
qty: 3, maxPerOrder: 12, qty: 8, maxPerOrder: 12, qty: 8, maxPerOrder: 10,It clicks the next number along
You don't have to be on the number. Ctrl-a clicks the first number at or after the cursor on the line, so from the start of qty: 3, it finds the 3 by itself. Only that one number changes; the rest of the line is left alone.
Which counter?
The cursor is at the start of the line. You press 3Ctrl-a. What does the line say?
Fix the order form
Each quantity is off by a few. Read the right number from the goal, then click it there with a count and Ctrl-a or Ctrl-x.
This exercise needs a keyboard. Read on, and play it at your computer.
A row of counters
Select several lines and gCtrl-a clicks each line's first number once more than the line above: the first gets +1, the second +2, and so on. A column of zeros becomes 1, 2, 3, 4. Take the selecting as a recipe for now: V highlights the line you're on, each j stretches the highlight down a line, and gCtrl-a works on what's highlighted. Track 7 is all about selecting.
Number the tickets
Every kitchen ticket says id: 0. Give them 1 to 4 in one go: V, j down to the last one, gCtrl-a.
This exercise needs a keyboard. Read on, and play it at your computer.
Chapters and clicks
From memory.
Inventory count
Quantities all over the codebase, each a few off. Click every one back to the right number with a count.
This exercise needs a keyboard. Read on, and play it at your computer.
Closing stock
The day's deliveries, in inventory.ts: 60 more tortillas, a crate of 12 for each of the four lines below it, then 5 churros sold. The four crates are the same change four times; one tip: . remembers a count too.
Stuck? Show a hint
tortillas: 60<C-a> · the next four: 12<C-a>, then j. j. j. · churros: 5<C-x>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.
Stocktake
Endless quantities to click back into place, a few at a time.
This exercise needs a keyboard. Read on, and play it at your computer.