tags:

views:

47

answers:

1

I want to replace a selection of text with is present in the default paste buffer. Say, I yanked a word with yaw and now I want to replace a word with that, how do I do it?

I saw similar questions answered with suggestions to use a named register and delete the text-to-be-replaced into the black hole etc, but I am looking for a cleaner solution.

+3  A: 

Visually select the range, then type p.

Paul Tomblin
why didn't i think of that!!
blahster
If you want to keep the contents of your default register, in order to paste it another time, do like me: `xnoremap p pgvy`. @Paul Tomblin: Could you edit your answer maybe to include it?
Benoit
@Benoit, what does that do? Obviously it maps 'p' to 'p' followed by 'gv' by 'y', what what does 'gv' do?
Paul Tomblin
@Paul Tomblin: why don't you ask vim help? `:h gv` >> Start Visual mode with the same area as the previous area and the same mode. In Visual mode the current and the previous Visual area are exchanged. After using "p" or "P" in Visual mode the text that was put will be selected.
Benoit