Markdown内的Vim语法和Latex数学 [英] Vim syntax and Latex math inside markdown
问题描述
我使用ViM在markdown中编写文档,我也使用乳胶$$
符号进行数学运算(我使用pandoc进行编译).问题是ViM语法不会忽略美元符号内的下划线_
,这很烦人.例如,如果我这样写:
I write documentation in markdown using ViM and I also put math using the latex $$
symbol (I compile using pandoc). The thing is that ViM syntax wouldn't ignore the underscores _
inside the dollar symbols and it is pretty annoying. For instance if I write this:
$$ a_1 = 0 $$
然后,由于使用了下划线,Vim会用斜体突出显示以下所有文本.
Then Vim will highlight all the following text as italics due to to the underscore used.
我该如何更改?
如果我能用不同的格式突出显示$
中的内容,那也很好.
Also it would be nice if I could highlight what's inside $
with a different format.
推荐答案
我已将这些行放在我的.vimrc中.它适用于同一行上的内联数学和块模式数学.
I have put these lines in my .vimrc. It works for inline math on the same line and block-mode math.
" This gets rid of the nasty _ italic bug in tpope's 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
此后,我写了一篇博客文章,名为 查看全文