This question already has an answer here:

Can vim substitute automatically depending on the case ?

like : s/foo/bar/ turns Foo to Bar and foo to bar ?

marked as duplicate by Luc Hermitte, nobe4, grodzik, Community Jan 16 '17 at 10:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


I think the easier solution to that is to use the abolish plugin by Tim Pope. Once it is installed you can use the :S command. For example if you have this file:


And run :%S/foo/bar/ you'll get:


It also provides a lot of command to play with different cases.

Edit As @LucHermitte said, if you already have the :S command used for something else, you might want to use the complete name of abolish's function: :Subvert

  • 1
    In case the user has a plugin that defines command(s) starting with a capital S, it may be better to provide the full command name. – Luc Hermitte Jan 16 '17 at 7:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.