Target text: "This is a sample text with some words like hello123 and bye456." I want to match each word in that text.

/\v[\w]+ in Vim is bad, it can only match every "w". What is wrong?

I have tried other things:

[\w]+ in online normal regex tool is good.

/\v(\w)+ is good in Vim.

/\v[A-Za-z]+ is good in Vim too.

  • Don't use "online normal regex tool" for Vim patterns. Use :help pattern
    – D. Ben Knoble
    Commented Jul 25, 2023 at 13:46

1 Answer 1


In Vim within the collection operator [] the only constructions that are allowed are:

  • individual characters (e.g. a)
  • range of characters (e.g. a-z)
  • character class (e.g. [:alnum:])
  • the escaped character that have a special meaning in collection (i.e. \-, \], \^ and \\)
  • the standard escaped characters (e.g. \n, \r)

In particular not characters atoms like \w, \a, \d, ...

Remark: whenever applicable, for performance reason use character atom like \d, \a or \w instead of the corresponding collections.

More information with :help /[]

  • 1
    Thanks for digging this up. I think the complete list of supported backslash codes is found below :help /\], third bullet point.
    – Friedrich
    Commented Jul 25, 2023 at 6:57
  • Might be worth mentioning that what the OP (probably) wants is \v\w+.
    – D. Ben Knoble
    Commented Jul 25, 2023 at 13:45
  • @D.BenKnoble Thank you. I just want to know what is wrong.
    – littlecode
    Commented Jul 25, 2023 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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