I'm writing a syntax file. To highlight strings, I'm defining a region just like it says in the help file:

syn region m2String start=/"/ skip=/\\"/ end=/"/

and later I have:

let b:current_syntax = "m2" hi def link m2String String

However, this isn't behaving the way I want it to. After some experimenting, I figured out that vim is only highlighting strings if the character before the first quotation mark is a letter. Here's a screen shot:

example of my wonky syntax highlighting

Does anyone know why this is happening and how to fix it? If it helps, I'm using vim version 7.4.1689 in the terminal. My terminal is xterm-256color.

  • You probably want to do something with contained and/or contains keywords in some :syntax command, but without seeing the full syntax with you're trying to modify it's a bit hard to say where exactly. Jan 1, 2017 at 22:10

1 Answer 1


I found the culprit: the original author of this syntax file included the line syn match m2Keyword /\A\+/. I guess this matched the first quotation mark before the string region did.

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.