3

Haven't been able to figure this out...

So I usually like to select a word (say, albatross) and copy it to a register using v i w y, which–as I understand it–copies it into the * register.

Then I want to paste it back over another word (sparrow), so I'll do v i w p.

But often I'll want to paste the original word (albatross) over yet another word (osprey), but when I try to repeat my past commands, the pasted value comes out as sparrow, not albatross. This, I know, is because when the text is deleted before being pasted, it's copied into the * register, overwriting albatross with sparrow.

I thought I could work around this by using named registers, so I tried copying with v i w " 1 y and pasting with v i w " 1 p, but that just reproduces my original problem with the * register using the "1 register.

To all you VIM ninjas out there, what am I doing wrong? I'd like to be able to quickly yank some arbitrary text (preferably using the * register, as it saves me two keystrokes) and paste that original value n times afterwards at any point in the document.

How is something like this done efficiently?

neezer
  • 733

2 Answers2

6

The 0 register holds the last text yanked, so once you yank some text, you should be able to paste it over and over again with "0p. For more about this, see

:help quote0
garyjohn
  • 36,494
3

You should use the "a to "z (named) registers, instead of the numbered registers, which stores previous deletes automatically.

Bernhard
  • 1,143