Vim syntax and Latex math inside markdowns

I am writing documentation in markdown using ViM, and also adding math using the latex $$ symbol (compiling with pandoc). The fact is that ViM syntax will not ignore underscores _ inside dollar characters, and this is pretty annoying. For example, if I write this:

$$ a_1 = 0 $$

Then Vim will highlight all subsequent texts in italics due to the underline used.

How to change this?

It would also be nice if I could highlight what's inside $ with a different format.

+6
source share
1 answer

I put these lines in my .vimrc. It works for embedded math on the same line and in block mode.

 " This gets rid of the nasty _ italic bug in tpope vim-markdown " block $$...$$ syn region math start=/\$\$/ end=/\$\$/ " inline math syn match math '\$[^$].\{-}\$' " actually highlight the region we defined as "math" hi link math Statement 

edit: I have since written a blog entry entitled " Vim syntax highlighting for Markdown, Liquid, and MathJax "

+7
source

All Articles