Yank & put
y puts a copy in the jar, p and P pour it out after or before. Deletes fill the jar too, so xp and ddp swap letters and lines.
Tuesday, 1:15 p.m. The menu team drops by with tomorrow's special: barbacoa. It's almost exactly carnitas, an item you already have: same shape, a different name, a slightly higher price.
Copying a line is yy, you know that. Where does the copy go, and how do you get it back out?
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
One jar
Picture a jar on the kitchen shelf. y puts a copy of what its noun covers into the jar, and nothing on screen changes. p pours the jar back out, after the cursor. So yy then p copies a line and puts the copy right below it: a duplicate in three keys.
export const menu = [ { id: "carnitas", name: "Carnitas", price: 10 },];export const menu = [ { id: "carnitas", name: "Carnitas", price: 10 }, { id: "carnitas", name: "Carnitas", price: 10 },];p after, P before
P pours the same jar before the cursor instead. For a word you yanked with yw, that means right in front of the character you're on; p would put it right after.
Before or after?
The cursor is on the t of total. You press yw, then P. What does the line say?
Words in the jar
Two signs for the counter came back with their words swapped. On the first word, dw takes it (and its space) into the jar, w steps past the next word, and P pours it back in front of the cursor.
This exercise needs a keyboard. Read on, and play it at your computer.
Whole lines go on whole lines
The jar remembers what kind of thing it holds. Fill it with whole lines (yy, dd) and p doesn't split the line you're on: it pours them onto a new line below, and P onto a new line above, wherever the cursor is.
Clone the line
Each file is missing a copy of one line. Fill the jar with yy on the line to copy, then p.
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.
Deletes fill the jar too
Whatever you take out goes in the jar as well: x, dw and dd all fill it. So delete-then-put moves text. Two tiny recipes come out of that: xp swaps two letters (take one out, pour it back one later), and ddp swaps two lines.
kitchen.open();const kitchen = new Kitchen();kitchen.printer.warmUp();const kitchen = new Kitchen();kitchen.open();kitchen.printer.warmUp();Swap them back
Two letters in the wrong order (xp on the first of them), or two lines in the wrong order (ddp on the first of them).
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's in the jar?
You yy the carnitas line, press j, x the stray #, then p. What happens?
Refill the jar
That just happened in menu.ts. Take the wrong pour back with u, then do it in an order the jar survives: the stray # is already gone, so fill the jar with the carnitas line now and pour it below.
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.
Fill and pour
From memory.
Copy shop
Missing copies, swapped letters and lines in the wrong order, across the codebase. Fill the jar, pour it where it goes.
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.
Clone the specials
Barbacoa is carnitas with a new name and a price one higher. Make a copy of the carnitas line; in the copy, the id becomes barbacoa, the name Barbacoa and the price 11. Then barbacoa goes above carnitas, so the menu stays alphabetical.
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.
Copy shop, after hours
Endless copies to make and things to swap back.
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.