I would like to replace foo with bar and Foo with Bar. I can do
:s/Foo/Bar/g
:s/foo/bar/g
Can I do this in one command?
I would like to replace foo with bar and Foo with Bar. I can do
:s/Foo/Bar/g
:s/foo/bar/g
Can I do this in one command?
You could try this:
:s/\cfoo/\=submatch(0)[0] ==# 'F' ? 'Bar' : 'bar'/g
The replacement part of the substitution command is an expression which tests whether the first character of the pattern is F. If it is, the expression returns Bar, otherwise bar.