CodeFaster

CodeFaster

Share this post

CodeFaster
CodeFaster
Case preserving substitute in Vim

Case preserving substitute in Vim

Tyler Adams's avatar
Tyler Adams
Dec 30, 2021
∙ Paid
2

Share this post

CodeFaster
CodeFaster
Case preserving substitute in Vim
3
Share

https://stackoverflow.com/questions/782511/case-preserving-substitute-in-vim

Nobody in this thread understands vim. They think vim is about fancy things like submatch, and plugins. To solve a simple problem, they write terrible code which is only usable in vim. Can’t even re-use it in a script.

What nonsense.

vim, like unix, is not about fancy and complicated commands

vim is fundamentally a text editor within the unix operating system. Like other unix programs, its main value is playing really nicely with other programs.

In particular, you can pipe lines to any unix executable and write the result back into vim. An executable written in any language. Not stupid vim (only) script or emacs (only) lisp. But a language you already know. To write a generally reusable executable.

So, with this in mind, here’s a simple solution to the problem of a special find and replace.

I’ll punt the general case presented in stack overflow because I only care about something that does both:

foo → bar

Foo → Bar

…

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 Tyler Adams
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share