0

Quoting syn-pattern:

See |pattern| for the explanation of what a pattern is. Syntax patterns are always interpreted like the 'magic' option is set, no matter what the actual value of 'magic' is. And the patterns are interpreted like the 'l' flag is not included in 'cpoptions'. This was done to make syntax files portable and independent of 'compatible' and 'magic' settings.

Yet, I'm reading http://learnvimscriptthehardway.stevelosh.com/chapters/46.html and it gives this example:

syntax match potionComment "\v#.*$"

My interpretation of the doc is that the \v should be ignored.

I also see people asking on this issue for using very magic. https://github.com/pangloss/vim-javascript/issues/813

I'm getting mixed messages. Does the syntax pattern let you use the very magic option or not?

1

Yes, syntax patterns allow you to use "very magic".

Syntax patterns are always interpreted like the 'magic' option is set, no matter what the actual value of 'magic' is.

(emphasis mine)

I can see how you're reading this, but you just need to read it more literally. It does not state that the regular expression will be interpreted using "magic" rules. It states that it will be interpreted as if the 'magic' option is set.

Consider your example:

"\v#.*$"

How would this expression be interpreted if 'magic' were set?

The \v is present, so the setting is ignored and the remainder of the expression uses "very magic".

The documentation is only relevant to expressions where you're not specifically stating what level of magic you want to use. If you are specifically selecting this, then the option would be ignored anyway, and the documented behaviour does not come into play at all.

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.