The Yank That Survives

The problem everyone hits

You yank a line. Then, before pasting, you delete a different line — because that is how real editing goes. Then you paste, and you get the deleted line, not the yanked one.

What actually happened

Vim has an unnamed register, and both yank and delete write into it. Your delete simply landed on top of your yank.

But Vim also kept the yank somewhere safe, and has been doing so all along.

Register zero

"0p

There it is — exactly the line you yanked. Register 0 only ever holds your last yank. Deletes never touch it.

The deletes are not lost either

RegisterHolds
"0last yank
"1most recent delete
"2"9older deletes, in order
:reg

shows the whole cupboard at once — every register and what is in it.

Next time a paste gives you the wrong thing, you do not need to retype it.