Search notes:

VIM: Regular expressions

Non greedy matches
negative lookahed
negative lookbehind
to upper and lower case
match at specific columns only

Lookaround assertions

The lookaround assertions in vim are as follows:
Positive Negative
Look-ahead ATOM\@= ATOM\@!
Look-behind ATOM\@<= , ATOM\@42<= ATOM\@<! , ATOM\@42<!
The special forms \@42<= and ATOM\@42<! limit the range that is searched to 42 bytes.
TODO: \& works the same as using \@=: foo\&.. is the same as \(foo\)\@=... But using \& is easier, you don't need the braces.

Magic, very magic, no magic, very magic

A pattern can be interpreted in one of four ways.
The option magic, nomagic determines if it is interpreted magic nor non-magic. Within the pattern, this can also be forced using \m (magic) and \M (non-magic).
In addition, \v forces very magic, \V forces very non-magic.
With very magic, all ASCII characters except alpha-numeric ones (09, az, AZ and _) have a special meaning.
With very non-magic, in order for a character to become a special meaning, it must be preceded by a backslash. In addition, the pattern terminating characters (/ (or ?)) have obviously a special meaning.
As per this Stackoverflow answer, there is way to permanently or globally enforcing very magic. As alternative, it is suggest to use the mapping :cnoremap s/ s/\v.

Search for unicode characters

A unicode character can be indicated with \%u:
Search for hebrew letter א (unicode character U+05D0):
/\%u05d0
Searching for a unicode range. The following regular expression searches for hebrew characters between ב (U+05D1) and ד (U+05D3):
/[\u05d1-\u05d3]

:help perl-patterns

:help perl-patterns lists a few differences between Perl's flavor of regular expressions and Vim's flavor.
Perl Vim
Force case sensitivity/in-sensitivity (?i), (?-i) c, C
Backref-less grouping ?:atom \%(atom\)
Conservative quantifiers (aka non-greedy matching?) *?, +?, ??, {}? \{-n,m}
Zero-width match, non-match (?=atom), (?!atom) atom\@=, atom\@!
Zero-width preceding match, non-match (?<=atom), (?<!atom) atom\@<=, atom\@<!
Match without retry (?>atom) atom\@>

See also

VIM script: regular expressions
regular expressions
The logiPat plugin offers boolean-logic based on regular expression pattern matching.

Index