What is the easiest way to replace all occurrences of string_a with string_b while at the same time changing anything that was already string_b into string_a? My current method is as follows:
:s/string_a/string_c/g
:s/string_b/string_a/g
:s/string_c/string_b/g
Although this works, it requires extra typing and seems inefficient. Does anybody know of a better way to do this?
I’d do it like this:
But that’s too much typing, so I’d do this:
But that still requires typing
fooandbartwice, so I’d do something like this:If one of your words contains a
/, you have to pass in a delimiter which you know none of your words contains, .e.gThis also has the benefit of being able to swap multiple pairs of words at once.