Lookaround assertions
| 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 (
0
…
9
,
a
…
z
,
A
…
Z
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
.