5 ms·
This reminds me of the substitution mode of Tim Pope's amazing vim plugin [abolish](https://github.com/tpope/vim-abolish?tab=readme-ov-file#substitution https:/
by WizardClickBoy 2y ago
This reminds me of the substitution mode of Tim Pope's amazing vim plugin [abolish](https://github.com/tpope/vim-abolish?tab=readme-ov-file#substitution https://github.com/tpope/vim-abolish?tab=readme-ov-file#subs...)
Basically in vim to substitute text you'd usually do something with :substitute (or :s), like:
:%s/textToSubstitute/replacementText/g
...and have to add a pattern for each differently-cased version of the text.
With the :Subvert command (or :S) you can do all three at once, while maintaining the casing for each replacement. So this:
textToSubstitute
TextToSubstitute
texttosubstitute
:%S/textToSubstitute/replacementText/g
...results in:
replacementText
ReplacementText
replacementtext
- WizardClickBoy 2y agoAlso just realised while looking at the docs it works for search as well as replacement, with: :S/textToFind matching all of textToFind TextToFind texttofind TEXTTOFIND But not TeXttOfFiND. Golly!
- gen220 2y agoIn vim, I believe there's a setting that you can flip to make search case sensitive. In my setup, `/foo` will match `FoO` and so on, but `/Foo` will only match `Foo`
- WizardClickBoy 2y agoThere's undoubtedly a setting but if you don't want it on all the time you can always add \c at the end of the search term, like /foo\c to denote case insensitivity
- User23 2y agoThe Emacs replace command[1] defaults to preserving UPCASE, Capitalized, and lowercase too. [1] https://www.gnu.org/software/emacs/manual/html_node/emacs/Replacement-and-Lax-Matches.html https://www.gnu.org/software/emacs/manual/html_node/emacs/Re...
- tambourine_man 2y agoOf course it does. Or it wouldn’t be Emacs