Unnamed and yank registers
The jar you know is one of a shelf: p pours the everyday jar that every yank and delete refills, and "0p the yank jar that only yanks fill.
Friday, 3:10 p.m. Demo day went well, and the kitchen celebrates by putting the secret salsa on the menu. Its recipe has two TODO lines where the kitchen wants the tomatoes again (charred twice: that's the secret). You copy the tomato line with yy, go down, delete a TODO with dd, press p, and get the TODO back.
The delete refilled the jar. But the jar you've been using all along isn't the only one on the shelf.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
A shelf of jars
In the kitchen rewrite you met the jar: y fills it, d fills it, p pours it. That jar is the everyday one, and it has a label, ". Next to it stands a jar labelled 0 that only takes yanks. Delete all you like: 0 still holds what you last yanked.
"TODO",↵ "4 tomatoes, charred",↵TODO: the everyday jar holds the TODO, the jar labelled 0 still holds the tomatoes.Say the label, then pour
To pour a particular jar, say its label first: "0p puts what's in jar 0. So the recipe fix is yy on the line you want, dd on the placeholder, and "0P to put the yank back where the placeholder was. The next placeholder takes dd and "0P again: jar 0 is still full.
Why P and not p? After dd, the cursor sits on the line that moved up into the gap. P puts above it, into the gap; p would land one line too low. That's the label's job and the letter's job, kept apart: 0 says which jar, P says where.
Fill the gaps
Both TODO lines should be the tomato line. yy it, then dd and "0P on each TODO.
This exercise needs a keyboard. Read on, and play it at your computer.
Which jar pours?
You yy the salsa line, go down, dd the TODO line, and press p. What does the file say?
Pouring while typing
Jars pour in Insert mode too, as you saw in Monday's rehearsal: Ctrl-r0 pours jar 0 where you're typing. After ci" has emptied a string (and refilled the everyday jar with what it deleted), Ctrl-r0 still pours the word you yanked.
The name everywhere
Copy the special's name (yi"), then replace both TODO strings with it: ci", Ctrl-r0, Esc.
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.
Two jars, from memory
Press the keys.
The menu card
The printed menu card wants the salsa line under every dish, in place of each TODO, and once more at the very end. Two small fixes on the way (a doubled word, rice that should be beans) refill the everyday jar. The salsa line is copied once, at the start.
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.