Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vim语法优先级可以颠倒吗?_Vim_Vim Syntax Highlighting - Fatal编程技术网

vim语法优先级可以颠倒吗?

vim语法优先级可以颠倒吗?,vim,vim-syntax-highlighting,Vim,Vim Syntax Highlighting,以下是:help syn priority的条目 PRIORITY *: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 Keywo

以下是
:help syn priority
的条目

PRIORITY                        *: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.
规则
3
似乎覆盖了规则
1

是否可以使规则
1
优先于规则3?

这是一个不受欢迎行为的具体例子。使用以下语法文件,似乎
nTODO
的优先级高于
boldme

syntax clear
syntax case match

syntax match nTODO /^\s*!!.*/ 
syntax match boldme /\*.\+\*/

highlight nTODO  ctermfg=Yellow
highlight boldme ctermfg=Red
要匹配的输入示例:

This *line* has one word Red.
!!This line is completely yellow.
!!This line is also *completely* yellow, but I want one word to be red.

您正在查找嵌套匹配工具,请参见
:help syn contains

   :syntax match boldme /\*[^*]\+\*/
   :syntax match nTODO /^\s*!!.*/ contains=boldme

无论是否包含,我仍然希望在boldme上进行匹配,因此看起来我必须为
innerBold
定义两次匹配,一次使用
contained
关键字,一次不使用关键字。我接受,因为它解决了问题,但是如果你知道没有冗余的方法,请更新。我错过了这个,我将留给我的神经病理学家,但事实证明“包含”关键字不是必需的。