:g and :v
A slip that picks its lines by what they say: :g/pattern/ every line that matches, :v/pattern/ every line that doesn't, then any order: :g/console\.log/d↵, :v/courier/d↵, m$ (move below the last line).
Thursday, 3:00 p.m. The cleanup list before tonight's release: every console.log line goes, the TODO(rider) notes move to the bottom of their file so someone deals with them, and from the dispatch log only the courier lines are wanted.
None of those lines have numbers you know. What they have in common is what they say.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
Every line that says…
:g/pattern/ names the lines for the slip by what's on them: every line that matches. Then the order, carried out on each of them in turn: :g/console\.log/d deletes every line with a console.log on it. (The backslash makes the dot a real dot, from the search track.)
const c = pick(order);console.log("here", c);assign(order, c);console.log("done");const c = pick(order);assign(order, c);d: the two log lines gone, wherever they were.Purge the debugging
Debugging lines left in three files. One :g slip for each.
This exercise needs a keyboard. Read on, and play it at your computer.
…and every line that doesn't
:v/pattern/ turns it round: every line that does **not** match (:g! means the same). From a log, :v/courier/d deletes everything that isn't about couriers, which leaves only the lines you wanted.
09:58 rider 12 online10:02 kitchen ticket 440110:03 courier 7 picked 440110:05 payment ok 440110:03 courier 7 picked 4401courier, deleted: what's left is the courier lines.Only the couriers
Keep only the lines of the dispatch log that mention a courier. One slip.
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.
What survives?
You send :v/courier/d↵ on these three lines. What is left?
Every empty line
You send :g/^$/d↵. What is left?
Any order at all
After :g/pattern/ can come any order on the slip. m$ is move below the last line: m for move, $ for the last line, as in a range (two chapters on, :m gets a chapter of its own). So :g/TODO(rider)/m$ moves each matching line to the bottom of the file, one after another, which keeps their sequence. And :g/pattern/normal … runs Normal-mode keys on each, as you did with a recipe card on Monday.
Notes to the bottom
Move both TODO(rider) notes to the bottom of the file, keeping their sequence. One slip.
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.
Every line that…, from memory
Press the keys.
order.order.Cleanup
Five files, and the line under the editor says what each one wants: lines to delete, lines to keep, lines to move, gaps to close, and a rename on some lines only. Say "every line that…" to yourself first; any slip that leaves the right text counts.
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.