gpt4 book ai didi

vim - 如何让vim解析quickfix窗口的多行错误信息?

转载 作者:行者123 更新时间:2023-12-04 23:23:37 26 4
gpt4 key购买 nike

我想使用 make 在 vi​​m 下运行我的应用程序,我想要 quickfix窗口显示我的错误。

所以我有这个格式,它首先以 Error: 开头然后文件名,行和列由 : 分隔然后在下一行,会有一条没有特殊格式的多行消息,然后消息将以 ErrorEnd 结尾。 .

所以这是一个例子:

Error: /somefile/something/something.c:12:123
SOME MESSAGE
ANOTHER HELPFUL MESSAGE
ANOTHER MESSAGE
ErrorEnd

我有点迷失在如何使它与这些行匹配的文档中。一切似乎都如此令人困惑,而且示例与此不同。我知道如何让它匹配第一行,但不知道如何让它匹配下一行作为错误消息。所以问题是可以解析所有内容的错误格式字符串是什么。

最佳答案

从 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

编辑:啊,你的意思是多行错误。对。那更难。

关于vim - 如何让vim解析quickfix窗口的多行错误信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17560652/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com