I used to do n.n.n.n. to do the same (i.e. /search something, then do the replacing with something like cw or 3s or ct' or whatever you want, and then hit n for next result and . to repeat the change). Using cgn is less flexible and you need to learn another thing (you know about n and . already by the time you get to cgn), and maybe it's just me but hitting n. repeatedly is practically equally fast as just hitting the dot.
It also has the downside that it doesn't match what is being shown: when I hit * on "overview" it highlights both "overview" and "Overview" (I have highlight search enabled), but cgn replaces only one of them. When the cursor is on Overview and I run "*cgnexample<esc>..." it will skip all the "Overview"s and only replace "overview".
But perhaps it's a bug in Vim since it works when I run * on the lowercase variant.
Ooooh that is great! I use *# every time and am then annoyed when the n key goes backwards instead of forwards and then I try to remember to do #* instead and pff... ^^ This will solve those issues!
> But perhaps it's a bug in Vim since it works when I run * on the lowercase variant.
Per the help it's a feature, and it's infuriating! (From :help star)
> 'ignorecase' is used, 'smartcase' is not.
Here's your workaround:
" By default, * and # respect 'ignorecase'. This mapping forces these commands
" to search case sensitively, which is usually what you want when searching
" code with * or #. May be less good for prose.
nnoremap <silent> * /\C\<<C-R>=expand('<cword>')<CR>\><CR>
nnoremap <silent> # ?\C\<<C-R>=expand('<cword>')<CR>\><CR>
It also has the downside that it doesn't match what is being shown: when I hit * on "overview" it highlights both "overview" and "Overview" (I have highlight search enabled), but cgn replaces only one of them. When the cursor is on Overview and I run "*cgnexample<esc>..." it will skip all the "Overview"s and only replace "overview".
But perhaps it's a bug in Vim since it works when I run * on the lowercase variant.