firedev
firedev

Reputation: 21088

Vim: What's the best way to have markdown automatically enabled for comments?

I would like to be able to format comments in code somewhat:

# **TODO**
#
# *Don't forget*

I want markdown syntax to be highlighted a bit but only in comments, add cterm=bold for \*\*(.*)\*\* or something.

Is there a way to do it in Vim?

Upvotes: 1

Views: 90

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172648

To do this properly, you'd have to :syntax include the markdown syntax into each individual syntax (that has comments that you're interested in), and have it containedin= the corresponding syntax group for comments. That's doable, but requires some effort (depending on how many and which syntaxes to modify).

It's quicker to use a plugin like my SyntaxRange plugin to change the syntax of those comment blocks to markdown (manually, and on demand). With a corresponding mapping, this can be set up quite easily (but it's not automatic as the first alternative).

Upvotes: 1

Related Questions