Turn off highlighting a certain pattern in vim

吃可爱长大的小学妹 提交于 2019-12-05 10:45:47

You have to modify the Markdown syntax for that. One way would be to remove the parsing of the error:

:syn clear markdownError

But that would cause the other syntax rules to start an italic section on that _ char. Better just clear the error highlighting with:

:hi link markdownError Normal

To maintain the general error highlighting, but only define exceptions for the special $x_i$ string, define an overriding syntax group; luckily, this is easy because no existing syntax is there:

:syn match markdownIgnore "\$x_i\$"

(Adapt the regular expression to match all possible math expressions.) This needs to be put into ~/.vim/after/syntax/markdown.vim to be executed after the original syntax script.

If you want to remove _ from the markdown error pattern, you can redefine it. In my case I want to turn off error notifications of underscores in a word as I put a lot of URLs in my documents.

There's a line that defines the error pattern inside syntax/markdown.vim file

" Original error pattern
syn match markdownError "\w\@<=_\w\@="

Remove the _ from the pattern and add that to ~/.vim/after/syntax/markdown.vim.

" New error pattern without the underscore
syn match markdownError "\w\@<=\w\@="
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!