Can vim substitute automatically depending on the case ?
like : s/foo/bar/
turns Foo
to Bar
and foo
to bar
?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityI think the easier solution to that is to use the abolish plugin by Tim Pope. Once it is installed you can use the :S
command. For example if you have this file:
foo
Foo
FOO
And run :%S/foo/bar/
you'll get:
bar
Bar
BAR
It also provides a lot of command to play with different cases.
Edit As @LucHermitte said, if you already have the :S
command used for something else, you might want to use the complete name of abolish's function: :Subvert
S
, it may be better to provide the full command name.
Jan 16, 2017 at 7:14