The 0 Buffer
Here's a Vim 101 thing that I went without knowing for far too long, so maybe it'll help you as well:
Say you have 3 lines of code ...
T-2000
John Connor's Foster Mom
Random Policeman
And you want to replace the second two lines with the first. You might type yy
to yank T-2000
, then type shift-v
and p
on line 2 to replace John Connor's Foster Mom
with T-2000
:
T-2000
T-2000
Random Policeman
But if you go to line 3 and type shift-v
and p
again, you'll paste John Connor's Foster Mom
, because Vim replaces the default buffer with the previously removed line.
Fortunately, T-2000
is still available in that scenario – it's automatically placed into the 0
buffer. To continue to paste T-2000
, just type:
"0 p
to paste from the 0
buffer instead of the default buffer.