Title here
Summary here
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.
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.
"0pThere it is — exactly the line you yanked. Register 0 only ever holds your last yank. Deletes never touch it.
| Register | Holds |
|---|---|
"0 | last yank |
"1 | most recent delete |
"2 … "9 | older deletes, in order |
:regshows 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.