How would one replace all instances of 'foo' with 'bar' and 'bar' with 'foo' in vim?
Take a look at this: how to write only one pattern to exchange two strings in two-ways in vim
:s/foo\|bar/\={'foo':'bar','bar':'foo'}[submatch(0)]/g
Aside from using a temporary word for the change, you could also use abolish plugin like this:
:%SubVert/{foo,bar}/{bar,foo}/g
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With