In Vim, replace all occurrences of current term under cursor
I went ahead and whipped up a plugin which lets you just enter the following:
:Dr REPLACEVALUE
https://github.com/chiedojohn/vim-dr-replace
In addition to the other answers, you could shave off some more keystrokes by adding following snippet to your .vimrc file for doing a global search and replace.
" Search and replace word under cursor using F4
nnoremap <F4> :%s/<c-r><c-w>/<c-r><c-w>/gc<c-f>$F/i
Just use * and then:
:%s//new value/
If you don't specify a pattern, the substitute command uses the last searched one.
Depending on the value of gdefault
in your configuration, you might need to add a /g
modifier to that command.
You can use:
:%s/<c-r><c-w>/new value/g
where <c-r><c-w>
means to literally type CTRL-rCTRL-w to insert the word under the cursor.