在编辑语法文件时,我发现类似以下内容:
\s*\%(\%(:\@<!\/\/.*\)\=\|\%(\/\*.*\*\/\s*\)*\)$
除了那里以外\%
,我都不熟悉\@
。我什至无法搜索,因为我不知道它的名字。那么它是什么,它做什么呢?
在编辑语法文件时,我发现类似以下内容:
\s*\%(\%(:\@<!\/\/.*\)\=\|\%(\/\*.*\*\/\s*\)*\)$
除了那里以外\%
,我都不熟悉\@
。我什至无法搜索,因为我不知道它的名字。那么它是什么,它做什么呢?
Answers:
谷歌搜索前,请尝试以下文档:
从 :h \%
\%(\) A pattern enclosed by escaped parentheses.
Just like \(\), but without counting it as a sub-expression. This
allows using more groups and it's a little bit faster.
{not in Vi}
和 :h \@<!
\@<! Matches with zero width if the preceding atom does NOT match just
before what follows. Thus this matches if there is no position in the
current or previous line where the atom matches such that it ends just
before what follows.
Like "(?<!pattern)" in Perl, but Vim allows non-fixed-width patterns.
The match with the preceding atom is made to end just before the match
with what follows, thus an atom that ends in ".*" will work.
Warning: This can be slow (because many positions need to be checked
for a match). Use a limit if you can, see below.
Example matches ~
\(foo\)\@<!bar any "bar" that's not in "foobar"
\(\/\/.*\)\@<!in "in" which is not after "//"
pattern.txt
文件包含有关这些项目的主题因此他们有帮助标签相关的(/\%(\)
或/\%(
或E53
为第一个和/\@<!
第二个之一),这些标签可以作为论据:h
。现在,关于它们的名称,我想说它们被称为原子,就像^
或一样.
,但我不确定100%。
:helpgrep
就是这样。:)
:help
可以接受模式作为参数。这是非常有价值的信息。顺便说一句,它没有名字,不是吗?