Within Vim to group some chars sequence usage of \( \) is required. The same behavior is for other specials: \{ \}.
Is it possible to change regex style to be like in perl? How to switch it?
Instead
\\(
I would
(
???
You can change the default required 'magic level'
:se nomagic
:se magic
See :he magic
I'd recommend using the corresponding escapes instead to avoid breaking your other mappings.
/\v(\d+)
will match consecutive digits like you'd expect with Perl Regex
From pattern.txt help:
Examples:
after: \v \m \M \V matches ~
'magic' 'nomagic'
$ $ $ \$ matches end-of-line
. . \. \. matches any character
* * \* \* any number of the previous atom
() \(\) \(\) \(\) grouping into an atom
| \| \| \| separating alternatives
\a \a \a \a alphabetic character
\\ \\ \\ \\ literal backslash
\. \. . . literal dot
\{ { { { literal '{'
a a a a literal 'a'
{only Vim supports \m, \M, \v and \V}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With