Due to a quirk in the domain-specific language I am working with, I frequently face the task of (selectively, not globally) replacing term or TERM with word or WORD, respectively.

This means, I search case-insensitively for term, and want to replace that with word while keeping the uppercase / lowercase of the original term intact.

Since checking the whole of term for consistent upper-/lowercase would be difficult and is not really necessary, I would settle for uppercase / lowercase of word / WORD being decided on the first letter of term.

How could I achieve this?

  • 2
    Note about the "selectively" for those who don't know it: Just add c to the end of the substitution statements below, and Vim will ask you about every single match.
    – DevSolar
    Dec 2, 2015 at 15:28

2 Answers 2


Michaels Geddes' plugin keepcase (GitHub) has all you need:


Other syntax elements from :substitute are also supported.

  • 5
    Brilliant... this will significantly speed up things for me. I also notice that I no longer ask "can this be done", but only "how to do it". Seems I've finally "arrived" at Vim. :-D
    – DevSolar
    Dec 2, 2015 at 11:03

This can be handled by the :Subvert from the abolish plugin:

One time I had an application with a domain model called "facility" that needed to be renamed to "building". So, a simple search and replace, right?


Oh, but the case variants!


Wait, the plural is more than "s" so we need to get that too!


Abolish.vim has your back. One command to do all six, and you can repeat it with & too!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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