一个非常老的帖子,但这是对 @dule 出色回答 的跟进。这只是微调,但它可能对其他人也有用(我花了一些时间去研究 TFM,所以为什么不分享呢?):
setlocal makeprg=jslint\ %
setlocal errorformat=%-P%f,
\%A%>%\\s%\\?#%*\\d\ %m,%Z%.%#Line\ %l\\,\ Pos\ %c,
\%-G%f\ is\ OK.,%-Q
有两个不同之处,都在第三行。首先,我用一个匹配零个或一个空格的模式替换了单个空格的初始硬编码匹配(即使空格是可选的)。我必须这样做,因为以下是jslint
的输出:
... First 8 errors trimmed
#9 Expected '$' at column 9, not column 7.
$('img#placeholder').attr('src', pic);
#10 Expected '$' at column 9, not column 7.
$('img#placeholder').attr('alt', desc)
仔细看,你会发现错误1-9开头有一个空格,而10到n没有空格。这是一个微小的问题,但它意味着快速修复窗口不能正确处理10及以上的错误。噫。(顺便说一句,我考虑了答案“不要在任何给定的JS文件中制造超过9个错误,但那似乎有点本末倒置。此外,现在我对scanf有了更多的了解。)
第二个区别是我用A替换了E,用一个模式来忽略匹配器n的数字。这基本上是为了美观的原因。按照@dule的方法,快速修复窗口会输出以下内容:
showPic.js|5 col 7 error 1| Expected 'event' at column 9, not column 7.
showPic.js|9 col 7 error 2| Expected 'var' at column 9, not column 7.
我不需要错误的计数,也不需要被提醒它们全部都是错误——我已经知道了。因此使用%A
,你可以得到如下更简单的输出:
showPic.js|5 col 7| Expected 'event' at column 9, not column 7.
showPic.js|9 col 7| Expected 'var' at column 9, not column 7.