Case-preserving search and replace in vim?

There isn't a native feature of :s that does this as far as I know, but if you're willing to install add-ons, you could look at Michael Geddes' keepcase plugin.


You can try this plugin.

https://github.com/tpope/vim-abolish

This plugin can help you to match not just the case sensitive text, also its variants too. Like /good{,ies} will match both good as well as goodies.

Similarly, it can replace with case sensitive as well as variant included.

      :%S/long/short/g

will replace long with short, Long with Short, LONG with SHORT.