How to write only one template for exchanging two lines in two directions in vim

xxx <=> zzz


Source text:

xxxyyyzzz

Launch command:

:s/???/???/

It will be:

zzzyyyxxx

Run the same command:

:s/???/???/

Return to source:

xxxyyyzzz


just how to switch case (~)

aBCdeFg aBCdeFg

+5
source share
3 answers

Try the following:

 :s/(...)(yyy)(...)/\3\2\1/ 
+3
source

You can always write your own macro. I assume that the macro for this particular example would not be useful to you, but I could post it if you want.

0
source

Source: https://habr.com/ru/post/908406/


All Articles