views:

43

answers:

1

Here is my problem:

I am in visual mode.

I select text and copy it to the buffer. ((y)ank)

I select another text which I want to replace and paste the buffer. ((p)aste)

Now the second selection has been replaced in the buffer, however I want the first one to still sit in there.

Any ideas?

+1  A: 

Often, this behavior is useful. When you don't want it, you can instead do the usual yank, then past (officially, 'put') with "0p. You can do this however many times you like.

See :help v_p for more.

If you want to avoid the overwrite, you need to delete first. You can use "_ to select the blackhole buffer, then delete d, then paste before P and you'll avoid the buffer being set.

Peter
Thanks Peter, I see, you use an explicit buffer to do the trick. Is there a way/setting to avoid the automatic population of the buffer by mere selection in the first place?
Juergen Riemer
unfortunately not (see the help mentioned). also, it's not the selection that does the setting, it's the pasting over the selection. I've added an alternative method to my answer though.
Peter
I see, well then your first suggestion seems to be the best way to do it. Thanks!
Juergen Riemer