0

how strictly does vim search and vim substitute follow regex? For example, this is a whole word search in regex:

\bwordtofind\b

but in vim normal mode, this command does NOT work:

/\bwordtofind\b

but some regex commands do work, for example, non-word barrier escape '\W' does work, ie:

/\Wwordwithnonwordcharssurroundingit/W

Why the inconsistency? Help me understand the logic behind vim search and vim substitute.

Kwolf
  • 2,001
  • 2
  • 12
  • 4
  • but why is not consistent with regex? that is my question. – Kwolf May 10 '17 at 17:00
  • i see that vim reserves '\b' for 'backspace'. I guess vim doesn't offer a distinction between ASCII character escaping and regex instructions in the even they have the same instruction. In regex, you can make a distinction between the two... – Kwolf May 10 '17 at 17:11
  • 1
    There is no such thing as a "one true regex syntax", there are at least 50 different dialects in common use. Vim implements a pretty rich one, but which is not compatible to Perl and Python regexes. You really should read `:h pattern`, it shall save you from a lot of hair pulling. – Sato Katsura May 11 '17 at 05:01

0 Answers0