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!
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.