Learn Practice Daily golf Reference
Registers·Lesson 1 of 4·8 min·0/6 exercisesPro

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.

Scene

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.

From memory

Warm-up from earlier chapters

Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.

Rub out the word you just typed.
press the keys…
1 of 2
Rub out the word you just typed.

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.

Afteryyjdd
"" "TODO",↵
"0 "4 tomatoes, charred",↵
After yy on the tomatoes and dd on the 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.

1export const SECRET_SALSA = [
2 "4 tomatoes, charred",
1 "1 onion, diced",
2 "TODO",
3 "2 chiles de arbol",
4 "TODO",
5 "salt, to taste",
6];
NORMALLoading the editor…2:1
Try it

Fill the gaps

Both TODO lines should be the tomato line. yy it, then dd and "0P on each TODO.

1 of 2Change the red text to 4 tomatoes, charred
1export const SECRET_SALSA = [
1 "4 tomatoes, charred",
2 "1 onion, diced",
3 "TODO",
4 "2 chiles de arbol",
5 "TODO",
6 "salt, to taste",
7];
NORMALLoading the editor…1/20.0s1:1

This exercise needs a keyboard. Read on, and play it at your computer.

Check yourself

Which jar pours?

1salsa
1TODO
NORMAL
Keys pressed: yyjddp

You yy the salsa line, go down, dd the TODO line, and press p. What does the file say?

Pick an answer (or press its number), then watch the engine prove it.

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.

Try it

The name everywhere

Copy the special's name (yi"), then replace both TODO strings with it: ci", Ctrl-r0, Esc.

Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

From memory

Two jars, from memory

Press the keys.

Put the last thing you yanked, even after deleting since.
scroll here, then press the keys3 keys
1 of 4
Put the last thing you yanked, even after deleting since.
Challenge

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
Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

The menu cardFinish the exercise above to see it.