Delete & change words
Word-sized sentences: dw takes the space, de doesn't, db reaches back; cw is the idiom; daw and ciw work from anywhere in the word.
Monday, 1:30 p.m. Further into kitchen.ts the variable names tell the history of the company: ordr from the first weekend, theOrderObjectNew from the consultant, q2 from someone in a hurry. Most of the rewrite is deleting and changing words.
The language has a few word-sized sentences, and one idiom you'll be glad of.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
To the next word, or to its end
dw reads delete to the next word, so from the start of a word it takes the word and the space after it: the right sentence when the whole word should go. de reads delete to the end of the word and stops at its last letter, so the space stays. And db reads delete back to the start of the word: from the middle of waitMinutes, it takes wait.
const total = await sumPrices(order.items);const total = await sumPrices(order.items);const total = await sumPrices(order.items);await: w takes the rest of the word and its space, e stops at its last letter, b reaches back to its start.Space or no space
Two trims. A doubled await has to go with its space: dw. Then waitMinutes becomes wait, keeping the space before the =: put the cursor on the M and de.
This exercise needs a keyboard. Read on, and play it at your computer.
cw, the idiom
Every language has idioms: phrases that don't mean exactly what their words say. cw is Vim's. By the rule it would take the space after the word too, but Vim reads it as change word, and a word doesn't include the space after it, so it stops at the end of the word. That's what you want when renaming: cw and the new name is the everyday rename.
Literal or idiom?
The cursor is on the o of ordr. You press cw, type order, and Esc. What does the line say?
The first weekend
ordr is from the first weekend, and it appears three times. Rename the first with cw from the start of the word, then slide to the start of each of the others and stamp it with .: a rename isn't done until every copy matches.
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.
A word, or the inner word
Two more nouns read like plain words. aw is a word: the word plus the space after it (or before it, if nothing follows), so daw deletes it cleanly from anywhere inside it. iw is inner word: just the letters, so ciw renames a word with the cursor anywhere in it: the spellcheck recipe from last week, and now you can read it. These nouns only work after a verb: on their own, a and i still start Insert mode. Track 6 is all about nouns like them.
return format(oldOrderTicket ?? ordr);return format(oldOrderTicket ?? ordr);Three eras
Misspelled names to fix with ciw, and doubled words to lose with daw. Neither needs you at the start of the word.
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.
Word sentences
From memory.
Rename the ancients
Ten names and leftovers from every era of Byte Burrito. Rename, delete, trim: one sentence each.
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.
The Kitchen class
The heart of kitchen.ts: the Kitchen class. Five fixes before anyone else opens this file: two doubled words lose their extra copy, lastOrderObjectNew becomes lastOrder, and two misspelled names get the spelling the rest of the class uses (order, next).
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.
Name patrol
Endless misspellings and doubled words, all over the codebase.
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.