Quite often I find myself in need of performing a substitution that will have matches sparsed all over a large file and with non-trivial search and replacement expressions.
For example, say I have some function calls like
okFunction(arg1, arg2 arg3). The args will differ with every function call, of course. Now say I have discovered a better function that doesn't need
arg2. I can easily adjust the entire file with
:%s/\<okFunction(\(\w\+\), \(\w\+\), \(\w\+\))/betterFunction(\1, \3)/gc
Although conceptually simple, I'm not sure I have got the syntax right in this rather long pattern. The
c flag really helps here, but the problem is that when asking for confirmation, vim will not show what the match will be replaced with. I mean, it will show the replacement expression, but not the evaluated result. If I confirm the substitution with
y, vim will immediately jump to the next match and I won't be abe to see if I made any mistakes.
I have found the vim-over plugin that partially solves the problem, but only if all mathes are visible on the screen when you are typing the command. Once you hit enter, the behavior is the exact same I described above and I don't get a preview.
So, is there a way to get vim to evaluate the replacement expression when asking for confirmation on substitute commands?