繁体   English   中英

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=\"%f\"\\,\ line\ %l:\ error(%n):\ %m

既然我们在这里,有没有一种快速测试efm的方法,而不是一直试着运行make?

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

:let &makeprg="cat ~/outputfile.log"
:make

关于进行错误格式化,这确实需要一些试验和错误。 您可以将%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%.%#'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM