3

:h \V tells me:

Use of "\V" means that in the pattern after it only the backslash and the terminating character (/ or ?) has a special meaning. "very nomagic"

However:

:echo ')' =~# '\V\[)]}>\]'   

Will tell me 0. How come so?

  • It's because your pattern expects a match for ')}>]'. This will match: :echo ')' =~# '\V\[)]' – Tommy A Jun 20 '16 at 20:45
  • 1
    But the special meaning of [ and ] would imply that it matches any of the enclosed characters; :echo 'a' =~# '\v[abc]' would match – hgiesel Jun 20 '16 at 20:47
  • Oh I see what the problem is now. I'll post an answer. – Tommy A Jun 20 '16 at 20:49
4

The problem is that you misplaced a slash. This is what it should look like:

:echo ')' =~# '\V\[)\]}>]'

\[] is a character collection with nomagic enabled. Note that it doesn't close with \]. Including an opening brace inside of the collection needs to be escaped with a slash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.