0

I'm writing a vim syntax script and I want to be able to make lines matching a certain pattern, say, '^>', "source" or imitate the markdown syntax highlighting.

Is there a way to do this at the syntax script level? Do I need to just copy and paste it in manually and make the proper adjustments? Does this require a modeline on the actual file?

Thanks!

1 Answer 1

3

Have a look at :help :syn-include. It allows you to import an existing syntax (like e.g. markdown) into a syntax cluster in your own syntax, and then you can assign syntax regions (if I understand you correctly, that would be a region starting with /^>/ and ending at the end of the line /$/) to it.

Note that success isn't guaranteed; you need some collaboration from the included syntax. (For example, if the markdown syntax anchors its patterns at ^, but now it's included behind the > prefix, it won't match any more.) In the worst case, you have to modify the included syntax or copy it completely into your own syntax.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.