简体   繁体   中英

How to override specific syntax rules for XML in vim?

In vim my html has end-tags highlighted the same as start tags, my XML does not:

I understand this is a problem with the theme I'm using which is this:

https://github.com/flazz/vim-colorschemes/blob/master/colors/codeschool.vim

But I'm not sure how to go about tracking down what to change, and where to override it. I would like the end tags to match the start tags.

You need to find out which syntax group causes the highlighting. :syn list shows all active groups, but it's easier when you install the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin. When you have the name of the offending syntax group, you can investigate where it comes from; (the last lines of) :scriptnames may help.

In XML, the start tag is highlighted by xmlTag and xmlTagName , whereas the end tag is highlighted by xmlEndTag . Usually, all three are linked to the built-in Identifier highlight group. You can investigate where this got changed via:

:verbose hi xmlEndTag
xmlEndTag      xxx links to Identifier
    Last set from /usr/local/share/vim/vim80/syntax/xml.vim

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM