Using Very Magic to Make Vim Regular Expressions Cleaner

Say you want to look for all regular expressions of the form “a*b*c*a*” in a file, and strip of the a’s in the beginning and in the end.
Without “Very Magic”:

s/a\(b*\)\(c*\)a/\1\2

Using “Very Magic”:

s/\va(b*)(c*)a/\1\2

Much cleaner. Keep in mind that the example above is a simple one. In longer examples the benefit might be more obvious.


Leave a Reply