0

When I reload my syntax file I receive this error:

E890: trailing char after ']': /v(.)@<=w+[nrs]/

Here's the line it's bugging out on, does anyone see why this doesn't work?

syntax keyword langMethod /\v(\.)\@<=\w+[]/
  • 2
    [] is an empty collection. Why do you have that in your pattern? – romainl May 10 '16 at 6:21
  • I apologize I copied the commented out version of my regex, the actual one has [\r\n\s] in the collection. – hhsnopek May 10 '16 at 14:58
  • 1
    Then the error message should be sufficient: you need to escape the backslashes. Try [\\r\\n\\s]. – romainl May 10 '16 at 15:44
  • Same error message as before, tho now the parsed regex looks as so: /v(.)@<=w+\r\n\s]/ Shouldn't there be a [ after w+? – hhsnopek May 10 '16 at 15:48
  • 1
    Does Neovim support patterns with syn keyword? I think Vim doesn't - all it allows is an optional tail (or abbreviation). – muru May 12 '16 at 20:08
1

Ok, I think I've figured it out. It has to do with your "very magic" option. You have a lookbehind: (\.)\@<=. However, in very magic mode you are not supposed to escape the @ in a lookaround.

On a slightly unrelated note, You have a \s in your character class []. You can't use shortcuts in character classes. (@muru pointed out that what you're looking for here with this character class is \_s which matches whitespace and newlines.) So the final expression I've come up with is the following:

/\v(\.)@<=\w+\_s/

See if that works for you.

It is my personal preference never to use the \v flag for this very reason. Too many exceptions to remember. I just like to use the default regex and learn one set of rules. :P

| improve this answer | |
  • 1
    To match newlines with \s: \_s. – muru May 12 '16 at 20:05

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.