What I need to do is yank a word (yw) and then move my cursor to a diffent location and "paste" the word over whatever follows the cursor without disturbing the other characters in the line

"yw" ...move cursor "p"

inserts the word. I need the put (p) to act as if it was coming from "R" mode


2 Answers 2


Replacing Several Occurrences with the Same Text in Visual Mode

I want to point out following: when you yanked and replaced the first occurrence with


and now want to repeat the replacement for another occurrence with


the inserted text is the one from the first replacement and not the originally yanked text which is something you might not want.

The default recommendation is to use the register "0 as following


However, I often have this situation and actually want to replace even more occurences. In this situation typing viw"0p felt too cumbersome and it is not dot repeateable which IMHO is a real pity. Therefore, I was looking for a more comfortable solution which matches my expectations.

I have settled with the plugin ReplaceWithRegister by Ingo Karkat which provides the new operator gr (overrides builtin gr). This changes the keys to press to


which is dot-repeatable. This means

griw or .

Registers: the Good, the Bad, and the Ugly Parts

Drew Neil has discussed this matter at length:

Additionally to ReplaceWithRegister he points following plugins out

The latter one is now split into smaller ones


I am also very new to vim, but I have a work-around for you (I think).

What worked on my machine is the following.

We start with the line:
first second third

Then in normal mode go to 's' of second and yw (to copy this word). Then go to 't' of third and delete the word with dw. Then use the last yanked text with "0P. Note the capital 'P', so that the yanked word is placed before the next.

(found this last part here: https://stackoverflow.com/questions/54255/in-vim-is-there-a-way-to-delete-without-putting-text-in-the-register).


My first google hit showed me this: https://stackoverflow.com/questions/14233498/replace-word-under-cursor-vim

The solution that is used there (and better than my own solution in my opinion) is:

1 "This first word should overwrite the second"

yiw     yank inner word (copy word under cursor, say "first").
...     Move the cursor to another word (say "second").
viwp    select "second", then replace it with "first". 

Is this what you wanted to do?

  • I don't know what I'm doing wrong. I put the cursor over the first word and type "yiw" and then move to the cursor to the next location where I want to put the word and start typing "viwp" and after I type "vi" the characters "wp" are placed in front of my cursor as if I had just typed "i" for insert. What am I missing?
    – mh2000
    Mar 5, 2019 at 21:50
  • 1
    @mh2000 v should start visual mode; iw is the text object for inner word. Verify your vim has these capabilities, and make sure there aren’t any mappings at play (it sounds like the i is triggering insert mode, suggesting vim isn’t recognizing iw)
    – D. Ben Knoble
    Mar 5, 2019 at 23:05
  • hmm... I'm using WinVi. Maybe that's a problem? When I get into work tomorrow, I'll move my files over to my Linux box and see if it acts differently there. thanks!
    – mh2000
    Mar 5, 2019 at 23:44
  • @mh2000 If the problem comes from WinVi, then it might make your question off topic for our site. Also according to the project page the developer stopped maintaining WinVi after Windows2000 (the last release was 7 years ago)... You can get much more recent version of Vim on windows which should give you less trouble.
    – statox
    Mar 6, 2019 at 8:28
  • I went to my Linux machine and tried this with the native VIM and it doesn't do what I want.
    – mh2000
    Mar 6, 2019 at 17:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.