Lines
Say the verb twice for the whole line (dd cc yy), D and C for the rest of it, and J joins lines.
Tuesday, 9:05 a.m. Below the Kitchen class in kitchen.ts is a graveyard: a debug flag left switched on, a setTimeout from the first weekend, comments about 2019, and one statement somebody split across two lines halfway through a thought.
Deleting it word by word would take all morning. The language has a way to say "this whole line".
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
Say it twice
Say the verb twice and it means the whole line. dd deletes the line the cursor is on, from anywhere on it. cc clears its text and starts typing (you met it as S), and yy copies it. No noun needed: saying the verb twice means the whole line.
kitchen.open();if (DEBUG) console.log("open");kitchen.printer.warmUp();kitchen.open();kitchen.printer.warmUp();Clear the graveyard
Each junk line has to go. Get onto it, anywhere, and dd.
This exercise needs a keyboard. Read on, and play it at your computer.
D and C: combos to the end
D is a combo like C: d$ ordered as one key. It deletes from the cursor to the end of the line, and C changes to the end, like c$. Perfect for a stale comment trailing after the code.
maxStops: 6, // TODO: ask dispatch maxStops: 6,Comments about 2019
Three trailing comments. Put the cursor on the space before each // and D.
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.
J joins
Someone split a statement across two lines. J joins the line below onto this one: it drops the second line's indentation and puts one space in its place. gJ joins without adding or removing anything, for the rare case when the space would be wrong.
What does J keep?
You press J on the first line. What do you get?
Put it back together
Each split line goes back together with J from anywhere on its first half.
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.
Line sentences
From memory.
Graveyard shift
Junk lines, split lines and wrong line endings across the codebase. Pick the line sentence that fits each one.
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.
Delete the dead
startShift, where the kitchen opens each morning. The DEBUG flag, the setTimeout and the debug log all go, whole lines. The warmUp call somebody split goes back onto one line. And the TODO trailing after return kitchen; goes, but the return stays: the shift needs it. Pick the line sentence that takes exactly that much.
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.
Night shift
Endless junk lines and split lines. Delete, join, 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.