1

I'd like to have rich syntax highlighting (using, say, markdown syntax) inside (single-line) comments (as is done in Rust). For now, I'm using the following code, which is not satisfactory.

syn include @markdown syntax/markdown.vim
syn region Comment start="///" end="$" contains=@markdown

It does handle syntax such as the following.

/// Comment with **bold** inside.

The first problem is that some markdown syntax (e.g., headings) match the beginning of line, so I would need to match markdown syntax after having removed the comment mark /// (and a single following space). Otherwise, comments such as the following are not highlighted as desired.

/// # Markdown heading (i.e., HTML h1)

Second, markdown syntax may span multiple lines, as in the case of titles. And separate comments lead to the contents being parsed separately.

This is a title
===============

Is there a simple way to do what I want?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.