16

I have a number of JavaScript files where the strings are snippets of HTML to be inserted into the webpage. Vim performs syntax highlighting on the JavaScript, and highlights the quoted strings as such. It seems to go beyond highlighting, in fact: within a quote, vim does not match the < that begins a tag with the > that ends it when using %; it seems to assume things like brackets don't exist in string literals.

Is there a way to indicate to vim that string literals should be treated as code in a separate language?

1 Answer 1

8

You will need to use contains keyword in a syntax file (see :help contains)

As an example of usage, see how the pythonDocTest syntax region is defined and used within a Python syntax file.

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.