[英]jslint vim errorformat
I have the jslint installed with npm on my system.我在我的系统上安装了带有 npm 的jslint 。
It produces error messages in the following format:它产生以下格式的错误消息:
1 1,9: Missing name in function statement.
function() {
2 2,11: Use '===' to compare with '0'.
if (x == 0) {
3 4,2: Unnecessary semicolon.
};
I wrote a compiler plugin for Vim to parse the error messages, but I could not figure out the problem with the errorformat
.我为 Vim 编写了一个编译器插件来解析错误消息,但我无法弄清楚errorformat
的问题。 I have the following now in my compiler file:我的编译器文件中现在有以下内容:
CompilerSet makeprg=jslint
\\ $*
\\ %
CompilerSet errorformat=
\%*[\ ]%n\ %l\,%c:\ %m,
\%-G%.%#
Which AFAIK should do the following:哪个 AFAIK 应该执行以下操作:
%*[\ ]
-- skip the whitespaces in the beginning of the line %*[\ ]
-- 跳过行首的空格%n
-- match the error number %n
-- 匹配错误号\
-- skip a space \
-- 跳过一个空格%l
-- match for the line number %l
-- 匹配行号\,
-- skip the comma \,
-- 跳过逗号%c
-- match the column number %c
-- 匹配列号:
-- skip the colon :
-- 跳过冒号\
-- skip the space again \
-- 再次跳过空格%m
-- match the error message %m
-- 匹配错误信息,
-- new line ,
-- 新行%-G%.%#
-- skip all the others %-G%.%#
-- 跳过所有其他It runs the jslint
which shows the messages but the :clist
command does not show any errors.它运行显示消息的jslint
,但:clist
命令不显示任何错误。
What am I missing?我错过了什么?
The problem was with the \,
, the skip comma, the correct format is:问题在于\,
,跳过逗号,正确的格式是:
CompilerSet errorformat=
\%*[\ ]%n\ %l%.%c:\ %m,
\%-G%.%#
The comma must be escaped with \\,
since ,
is a special char in errorformat, and \
is a special char in vim config file, which must itself be escaped.逗号必须用\\,
因为,
是错误格式的特殊字符,而\
是 vim 配置文件中的特殊字符,它本身必须被转义。 To vim, your error format is then %*[ ]%n %l\,%c: %m,%-G%.%#
, since the \
at the beginning of the line or before spaces are escapes for vim, not for the error format.对于 vim,您的错误格式为%*[ ]%n %l\,%c: %m,%-G%.%#
,因为行首或空格之前的\
是 vim 的转义,而不是对于错误格式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.