Some characters in the pattern are taken literally. They match with the same character in the text. When preceded with a backslash however, these characters get a special meaning.
Other characters have a special meaning without a backslash. They need to be preceded with a backslash to match literally.
If a character is taken literally or not depends on the magic
option and the items mentioned next.
|
Use of m
makes the pattern after it be interpreted as if magic
is set, ignoring the actual value of the magic
option.
Use of M
makes the pattern after it be interpreted as if nomagic
is used.
|
Use of v
means that in the pattern after it all ASCII characters except 0-9
, a-z
, A-Z
and _
have a special meaning. very magic
Use of V
means that in the pattern after it only the backslash has a special meaning. very nomagic
Examples
|
It is recommended to always keep the magic
option at the default setting, which is magic
. This avoids portability problems. To make a pattern immune
to the magic
option being set or not, put m
or M
at the start of the pattern.
Without v:
|
With v:
|
See also :h /v
近期评论