Operators speak a language
Commands are sentences: a verb (d delete, c change, y yank) and a noun, which is any motion you know. dw, ct,, d$.
Monday, 9:10 a.m. Since Friday's happy hour the kitchen display has shown every ticket three times. The code behind it is kitchen.ts, the oldest file in the repo, and it reads like it was written during a lunch rush: leftover arguments, dead flags, half-finished renames.
This week you rewrite it. That means cutting, a lot, and so far you can only cut one character at a time, or change the rest of a line.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
Verb, then noun
Vim's commands are a tiny language. d is a verb: delete. Every motion you know is a noun: w is to the next word, $ is to the end of the line. Put them together and you have a sentence: dw, delete to the next word.
const next = this.queue.shift(); const next = this.queue.shift(); const next = this.queue.shift(); const next = this.queue.shift();Every motion is a noun
f, t, b, e, W, 0, ^: every motion from track 1 is a noun now. After d, Vim waits for one, and the grammar bar reads your sentence back in words as you type it (you can switch it off in Settings). dt, reads delete till the comma; a count travels with its noun, so d2w is delete to the second word.
Cut the leftovers
Each green-boxed spot starts a leftover from an old rewrite. Get there, then say it in one sentence: d plus the motion that covers exactly the leftover.
This exercise needs a keyboard. Read on, and play it at your computer.
Read the sentence
The cursor is on the o of order. You press d2f,. What is left?
Change your mind
You press d, then think better of it and press Esc. Then you press w. What happens?
c: delete, then type
c is the verb change: it deletes what the noun covers and starts Insert mode, so one sentence takes out the wrong text and lets you type the right one. ct, changes everything up to the next comma; c$ changes to the end of the line (you met it as C). The spellcheck recipes were this verb all along: ciw is c with the noun inner word, and cgn is c with the next match.
const url = "http://localhost:3000";const url = process.env.API_URL;Say it right
Something between the brackets, commas or quotes is wrong. Start at the wrong part, c plus the motion that reaches its end, and type the right text.
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
y: copy
The third verb is y, yank: Vim's word for copy. It takes the same nouns (yw, y$, yt)) and changes nothing you can see. Where the copy goes, and how to put it back with p, is three lessons away.
Say the sentence
From memory: verb, then noun.
Trim the kitchen
Leftovers to cut and wrong values to change all over the codebase. One sentence each: the verb, then the noun that covers it exactly.
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
Three of every ticket
Found it: showTicket in kitchen.ts, with copies = 3. That 3 should be a 1. Then four leftovers, one sentence each: the legacy flag and the oldFormat argument go, the log message should say "ticket", and debugInfo(order) leaves the log call. Pick the noun that covers exactly what has to go.
Stuck? Show a hint
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis 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.
Ticket queue
Endless leftovers and wrong values. Verb, noun, next.
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.