VIM find all occurrences and replace with input
You're looking for:
%s/value_one/\=input('replace <'.submatch(0).'> with: ')/gc
:h :s\=
and :h input()
. You should be able to provide a default value for input if you wish.
This might not be the perfect, Just sharing what I used.
This assumes that :set hl
is set already. Pressing *
would search for the word under cursor. Bring the cursor to your word. But I usually use gd
instead of *
.
Then, change it using ciw
to replacement word. Then Esc
. We can now go to next occurence by n
.
If this need to be changed to the same word, then pressing .
does that.
If not, you can change to new value by using ciw
again.
If you don't intend to change next occurence, just skip it by pressing n
, which takes to next occurence.
This seems little manual, but this gives a conservative control over my edit.