Quoting Regex Metacharacters


If you don't know what a regex is, skip this section.

For those who understand what a regex is, and who realize that the "/" command takes a regex rather than just normal text, this will be important.

For the rest of you, it will seem totally out of place and should be skipped for now.

You should know how to use regular expressions, because a few tricks in regex will make your whole Unix/Linux/Mac experience a little better. It is too large a topic to expose fully here, but you might try looking at on of the goodreferences or tutorials elsewhere on the web.

The main thing to remember is that VIM will side with convenience when it comes to regex.

Since you search a lot, vim will assume that /+ means that you want to search for the nearest + character. As a result, all the metacharacters have to be quoted with the backslash ("\") character.

It's sometimes a pain, but if you really want to find a plus sign followed by a left-parenthesis, it is very easy.

No comments:

Post a Comment