加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-16 01:34:43 所属栏目:安全 来源:网络整理
导读:我希望非ascii字符显示为 here所讨论的,但是当非ascii字符在注释中时,语法高亮消失.稍微调查一下这个问题,我在vim-manual上发现,先前启动的项目具有更高的优先级(第3项).来自帮助:syn-priority: When several syntax items may match,these rules are used
我希望非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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读