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
endfunction
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?