1. Why doesn't this work?

If my text file is:

test bbbb test
test bbbb test
test bbbb test

I can yank aaa, select bbbb in visual mode, and type "0p, to replace it with aaa, with the idea of doing more replacements after (Or since vim 9.0, P has a similar effect).

Now if I place my cursor at the start of the next bbbb, and press ., bbbb is deleted. Why doesn't it paste aaa?

2. Is there a way to make it work?

I know that from visual mode, instead of "0p, I could do c<c-r>0<esc> to paste in insert mode, but I would rather not have to enter insert mode.


1 Answer 1


I don't remember a put in visual mode ever being repeatable with .. I guess not enough people complained about it.

Recording a macro before doing the first put would be one workaround (assuming the cursor is on aaa):

yiw    " yank current word
ww     " move cursor to target
qq     " start recording in register q
viw    " visually select current word
P      " put over visual selection
q      " stop recording
j      " move cursor to next target
@q     " replay macro from register q

but it may require a bit too much forward thinking, IMO.

See :help q.

Here is a quick and dirty custom operator that kills two birds with one stone:

  • is repeatable with .
  • follows the operator+motion model, like y or d

The snippet:

function! Put(type, ...)
    normal `[v`]P
nnoremap <silent> <key> :set opfunc=Put<CR>g@

In your use case, you would use it like this (assuming the cursor is on aaa):

yiw        " yank current word
ww         " move cursor to target
<key>iw    " put over current word
j          " move cursor to next target
.          " repeat

See :help :map-operator.

Note that the operator+motion model is amazing when there is a motion that suits your needs but falling back to visual mode is very helpful when there is no fitting motion. If that's the case, then I am afraid the suggested solution will be of no use.

Maybe you should open a feature request?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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