我希望使用make在vim下运行我的应用程序,并且希望quickfix窗口显示我的错误。
所以我有这样的格式,它首先以Error:开头,然后是文件名,用:分隔行和列,然后在下一行上,将有一条没有特殊格式的多行消息,然后消息将以ErrorEnd结束。
下面是一个例子:
Error: /somefile/something/something.c:12:123
SOME MESSAGE
ANOTHER HELPFUL MESSAGE
ANOTHER MESSAGE
ErrorEnd我有点迷失在如何让它与这些行匹配的文档中。每件事看起来都很令人困惑,而且示例并不像这个。我知道如何让它匹配第一行,但不知道如何让它匹配下一行作为错误消息。所以问题是,什么是可以解析所有内容的错误格式字符串。
发布于 2017-01-05 06:50:32
通过使用:help efm-ignore中描述的%+前缀和:help errorformat-multi-line中描述的多行错误格式说明符%E、%C、%Z等,您可以捕获错误消息中的多行文本。在您的特定示例中,似乎可以使用以下方法:
let &l:efm='%EError: %f:%l:%c,%-ZErrorEnd,%+C%.%#'注意与该行上的任何文本相匹配的%+C项,并将其添加到错误消息中。还要注意,我必须将%-Z项放在该项之前才能使用它,因为在解析该行时将使用第一个匹配的errorformat项。
发布于 2013-07-12 16:33:26
您是对的,解析快速修复的多行错误消息是很困难的。我甚至不确定是否有可能将这样一个块中的错误解析为单个错误。
对于笨重的错误输出,我采用的一种变通方法是向'makeprg'追加一个转换步骤(通常使用sed),该步骤将多行错误转换为传统的每行错误消息;类似于
Error: /somefile/something/something.c:12:123 SOME MESSAGE
Error: /somefile/something/something.c:12:123 ANOTHER HELPFUL MESSAGE
Error: /somefile/something/something.c:12:123 ANOTHER MESSAGE在你的情况下。
发布于 2013-07-12 16:50:33
从vim errorformat帮助页面:
Multi-line messages *errorformat-multi-line*
It is possible to read the output of programs that produce multi-line
messages, i.e. error strings that consume more than one line. Possible
prefixes are:
%E start of a multi-line error message
%W start of a multi-line warning message
%I start of a multi-line informational message
%A start of a multi-line message (unspecified type)
%> for next line start with current pattern again |efm-%>|
%C continuation of a multi-line message
%Z end of a multi-line message
These can be used with '+' and '-', see |efm-ignore| below.
Using "\n" in the pattern won't work to match multi-line messages.
Example: Your compiler happens to write out errors in the following format
(leading line numbers not being part of the actual output):
1 Error 275
2 line 42
3 column 3
4 ' ' expected after '--'
The appropriate error format string has to look like this:
:set efm=%EError\ %n,%Cline\ %l,%Ccolumn\ %c,%Z%m编辑:啊,你的意思是多行错误。正确的。这更难。
https://stackoverflow.com/questions/17560652
复制相似问题