I’ve run into the following case a few times and I was wondering if there is a fast way to handle it in Vim.
I’ll have a source file like the following:
#ifndef _FOO_H_ #define _FOO_H_ class Foo { Foo(int foo); }; #endif
And I would like to convert it to the following:
#ifndef _BAR_H_ #define _BAR_H_ class Bar { Bar(int bar); }; #endif
So, I want all foo -> bar, but to keep the capitalization of the original. Right now, I’ve been doing this with 3 or 4 different regexes, but it seems there should be a better way. Any ideas?
This script will do a case-preserving search/replace.
Copy the script to the plugin directory (
~/.vim/plugin), then do