0

My understanding of very-magic regexes is that you can escape any character outside [A-Za-z0-9_] with a backslash to make it match literally. However, I don't see that behaviour with CJK characters. For example, compare:

:echo match('中','\v中')         " succeeds (returns 0)
:echo match('中','\v\中')        " fails (returns -1)

Why?

Test environments

encoding=utf-8 in:

  • official GVim 7.4 Win32 with +iconv/dyn, +multi_byte_ime/dyn, and +multi_lang. (Strangely, it does not show +multi_byte, but UTF-8 editing works fine.)

  • Vim 8.0 with +iconv, +multi_byte, and +multi_lang running in Cygwin through mintty 3.0.0. $LANG is en_US.UTF-8.

1

According to :h /\v:

                            */\v* */\V*
Use of "\v" means that after it, all ASCII characters except '0'-'9', 'a'-'z',
'A'-'Z' and '_' have special meaning: "very magic"

It's ASCII characters, not any characters.

According to :h /\:

                            */\* */\\*
\x  A backslash followed by a single character, with no special meaning,
    is reserved for future expansions

Therefore, \中 has no meaning — it's just a reserved sequence.

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.