syntax highlighting between matching parenthesis

自作多情 提交于 2019-12-05 18:13:29

For clarity it is better to give each syntax region a bespoke name, and then link it to a standard colour group. I have renamed your original region redTeX.

You need to define a second region, innerBrace, defining the braces you want to ignore, and mark this region as transparent. Then redTeX should be marked to contain the transparent region, which it will then ignore.

syn region innerBrace start=+{+ end=+}+ transparent contains=redTeX
syn region redTeX start=+{\\color{red}+ end=+}+ contains=innerBrace
hi link redTeX WarningMsg

Note that in this case there is the added subtlety that redTeX itself matches as an innerBrace. I fixed this by marking innerBrace as containing redTeX.

Hope that makes sense!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!