在vim上将项目设置为更高的突出显示优先级

前端之家收集整理的这篇文章主要介绍了在vim上将项目设置为更高的突出显示优先级前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我希望非ascii字符显示here所讨论的,但是当非ascii字符在注释中时,语法高亮消失.稍微调查一下这个问题,我在vim-manual上发现,先前启动的项目具有更高的优先级(第3项).来自帮助:syn-priority:

When several Syntax items may match,these rules are used:

  1. When multiple Match or Region items start in the same position,the item defined last has priority.

  2. A Keyword has priority over Match and Region items.

  3. An item that starts in an earlier position has priority over items that start in later positions.

我目前正在使用这个:

Syntax match nonascii "[^\x00-\x7F]" 
highlight nonascii cterm=underline ctermfg=red ctermbg=none term=underline

我尝试使用选项nextgroup给nonascii匹配项更高优先级:

Syntax match nonascii "[^\x00-\x7F]" nextgroup=Comment

并包含选项:

Syntax match nonascii "[^\x00-\x7F]" contains=ALL

但它不起作用.我还尝试暂时禁用评论(突出显示清晰的评论)而没有达到预期的效果(我的评论没有突出显示,但是nonascii继续没有突出显示).我错过了什么?

是的,您的自定义语法组不匹配,因为已经有评论匹配(或现有语法脚本中的其他语法元素).

解决方案是告诉Vim你的nonascii组包含在那些组中,这样Vim就会尝试匹配那里(而不仅仅是在未着色的顶层).令其复杂的是注释的语法组取决于语法脚本,因此取决于文件类型(命名非常规则).在以下示例中,我使用了C和Vimscript文件名称

:Syntax match nonascii "[^\x00-\x7F]" containedin=cComment,vimLineComment
原文链接:https://www.f2er.com/bash/383391.html

猜你在找的Bash相关文章