How to replace '& =' with '= &' in Vim?

I tried replacing '& =' with '= &' in Vim, but the command :%s/&=/=&/g replaced '& =' with '= & ='.

Why did this happen? Which command should be used?

+6
source share
1 answer

Just remove the ampersand.

 :%s/&=/=\&/g 

You need to avoid this because & is the special character in the replacement, which will be replaced with the entire matched pattern.

+7
source

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


All Articles