Friday, March 18, 2011

timbit! How to escape parentheses in vim

You don't! By default grouping is turned off, if you will.
So if you have this: ((too many parens)) ((still too many))
You get rid of it like this:
:%s/((/(/g
:%s/))/)/g
And end up with this: (too many parens) (still too many)
But what if you want grouping? Then you will need to use the backslash for both parentheses. /\(free\)/
Do :help magic to get the details on when backslashes do and don't escape as you'd expect.