我正在尝试恢复cocoa.vim脚本。
Error detected while processing function objc#man#ShowDoc:
line 32:
E888: (NFA regexp) cannot repeat
函数objc #man#ShowDoc的第32行是:
let attrs = split(matchstr(line, '^ \zs*\S*'), '/')[:2]
首先,我不明白错误。什么在重复?什么不能重复?在线搜索该错误会让我看到它在vim的源代码中定义的位置,但它很迟钝,我不理解它。
其次,我觉得奇怪的是这个正则表达式曾经起作用,但现在它不适用于更新的vim。
我的vimscript体验非常少,而且regexp体验也不多。从那些做什么看的人的指导将非常感激。如果您感兴趣,Here是整个src。
答案 0 :(得分:4)
问题是\zs
是匹配正则表达式原子的开始。重复它零次或多次没有任何意义,因为你始终可以在\zs
点开始匹配。
当NFA引擎尝试生成正则表达式时,vim patch 7.4.421引入了此错误以阻止vim崩溃。很可能明星甚至不应该在那里。旧的正则表达式引擎允许它,但我不相信它做了任何有意义的事情。
你应该能够通过移除星星来修复它。
let attrs = split(matchstr(line, '^ \zs\S*'), '/')[:2]
(您也可以尝试将\%#=1
添加到正则表达式以强制使用旧引擎。您可能需要阅读:h E888
以查看它是否有用。我没有vim版本这个补丁级别现在要测试。)
:h \zs
的帮助复制如下。
/\zs
\zs Matches at any position, and sets the start of the match there: The
next char is the first char of the whole match. /zero-width
Example:
/^\s*\zsif
matches an "if" at the start of a line, ignoring white space.
Can be used multiple times, the last one encountered in a matching
branch is used. Example:
/\(.\{-}\zsFab\)\{3}
Finds the third occurrence of "Fab".
{not in Vi} {not available when compiled without the +syntax feature}