Search code examples
vim

vim case insensitive search with sensitive replace


I have a file with this in it:

test
Test

Currently, if If I want to replace all cases of 'test' with 'foo', and 'Test' with 'Foo', I have to use two commands:

:%s/test/foo/g
:%s/Test/Foo/g

Is there any way that I can accomplish this with a single command?


Solution

  • I think this vim plugin by tim pope will solve your problem, install it and %Subvert/{t}est/{f}oo/g or %Subvert/test/foo/g (thanks for the comment) will do the trick