Vim can also take a command that yields a list of filenames as a launch parameter via something like `vim $(ag -l target_string)`, letting you go through each file with a `:n`, letting you complete large refactors surprisingly quickly.
:%s/debug/dbg/c
vim will show the text which is about to be modified, and you have a prompt to confirm, skip, or quit (and some others).
And you would still need some nice mappings to substitute the word/selection underneath the cursor with :%s///gc.
(This is very unlikely to interest you, but I mention it for the sake of others. I’ve commonly seen people not really know about ranges especially, never stopping and thinking about what the % means (see `:help :%` if you don’t know), beyond possibly having encountered '<,'> by accident when pressing : in Visual mode (for explanation of these, see the help for :', '< and '>).)
You'd have to do *, then N to back to where you just were, then cgn, type your replacement, and then n., n., n., n (skip), n., etc.
With my plugin that just becomes one mapping, type your replacement, ., ., n (skip), ., etc.
It's just very smooth, which I like because I use this operation literally all the time. Hell, I'll even use it when changing a single variable, just to make sure there isn't another sneaky one in the file somewhere.
Works a treat!
Since Vim keeps an undo tree, you are guaranteed not to lose anything anyway.
To solve this I wrote a little plugin (that I finished as a plugin yesterday and uploaded just now): https://github.com/orlp/vim-quick-replace
It requires vim-repeat (and a patched one because the current one has an issue): https://github.com/orlp/vim-repeat
The nice thing is that it always jumps to the next match before replacing, and if you choose to replace the current match it immediately jumps to the next one, so that you can evaluate whether you want to replace it.
You can start in two quick ways: using the current word under the cursor or the current visual selection, so it's very flexible. For me replacing a variable name is often just putting my cursor on it, pressing space + r, typing the replacement name and then a couple .'s, n's and if I mess up some u's.
To see it in action: https://i.imgur.com/wEX6O1w.mp4