Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vim错误格式_Vim_Errorformat - Fatal编程技术网

Vim错误格式

Vim错误格式,vim,errorformat,Vim,Errorformat,我读了文件,但更困惑了。 编译器生成了以下错误: rot; ^ "cpp\c1.cpp", line 13: error(114): identifier "rot" is undefined 1 error detected in the compilation of "c1.cpp". 我知道如何检测给出错误行的行,但是我在错误列表中得到了额外的无用信息,错误消息被分成两行,我更喜欢合并 我的起始错误格式是: :set efm

我读了文件,但更困惑了。
编译器生成了以下错误:

          rot;
          ^
"cpp\c1.cpp", line 13: error(114): identifier
          "rot" is undefined


1 error detected in the compilation of "c1.cpp".
我知道如何检测给出错误行的行,但是我在错误列表中得到了额外的无用信息,错误消息被分成两行,我更喜欢合并

我的起始错误格式是:

:set efm=\"%f\"\\,\ line\ %l:\ error(%n):\ %m

既然我们已经这样做了,那么有没有一种不用一直运行make就可以快速测试efm的方法呢?

首先,我谈谈调试。不幸的是,没有特别简单的方法,但有一种有用的方法是运行make并将输出放入文件中,然后:

:let &makeprg="cat ~/outputfile.log"
:make
关于制作errorformat,这确实需要一些尝试和错误。您可以对多行邮件使用%A、%C和%Z,也可以使用%-G忽略内容。顺序非常重要,请注意,有时%C甚至%Z出现在%A之前!在您的情况下,您可以使用下面的efm到达某个地方。我倾向于使用
let&efm=
let&efm.=
而不是设置,因为你不必逃避每个空格或引号,你可以逐步建立它。它也更具可读性

" Start of the multi-line error message (%A),
" %p^ means a string of spaces and then a ^ to
" get the column number
let &efm  = '%A%p^' . ','
" Next is the main bit: continuation of the error line (%C)
" followed by the filename in quotes, a comma (\,)
" then the rest of the details
let &efm .= '%C"%f"\, line %l: error(%n): %m' . ','
" Next is the last line of the error message, any number
" of spaces (' %#': equivalent to ' *') followed by a bit
" more error message
let &efm .= '%Z %#%m' . ','
" This just ignores any other lines (must be last!)
let &efm .= '%-G%.%#'

无用的信息是什么?是不是有一个说明符错误地抓取了实际的编译器错误输出?这或许也能解释两行文字的信息?如果这是有帮助的,那么从源代码中获取的默认值(我在帮助中找不到它):
%f>%l:%c:%t:%n:%m,%f:%l:%t%*\\D%n:%m,%f%l%t%*\\D%n:%m,%*[^\“]\%f\”%*\\D%l:%m,%f:%l:%m,%f |%l |%m”
+1作为调试提示。在windows上,如果无法使用cat实用程序,可以使用
:let&makeprg type outputfile log.log“
根据要更改的位置,您可能希望使用
let&l:efm=
而不是
let&efm=
来获得
setlocal
等效行为。我特别想在Fielype插件或类似的VIM文件中考虑。这是第一个真正的理由,在C++代码中使用空格而不是标签,如果使用标签,编译器输出使用标签,%P^将失败: