Vim在执行:make命令后尝试跳转到不存在的文件

7

我正在使用来自vim的:make,并且最终跳转到存在问题的文件。

最近,至少我注意到在gcc 4.6.1下,vim会跳转到错误的文件 / 行,因为它会跳转到第一个报告有 "In file included from ABC.h |5| 0," 的行,而没有叫做"In file included from ABC.h"的文件。

从上面的行中提取文件名(在这种情况下是ABC.h)有解决方案,但这并不能解决问题,因为有问题的文件只是在那里被包含。

通常,下一行指示了问题所在的位置,这就是我想要跳转到的位置:

MyDir/FGH.h|56 col 32| error: 'bad bad thing happened here'

这个问题在 vim 中是否有已知的解决方案?
3个回答

4
这是一个在新版本Vim中已经解决的错误:错误报告日志-#62169
您可以使用以下设置来解决问题,而无需升级Vim:
  set errorformat^=%-GIn\ file\ included\ from\ %f:%l:%c:,%-GIn\ file
           \\ included\ from\ %f:%l:%c\\,,%-GIn\ file\ included\ from\ %f
           \:%l:%c,%-GIn\ file\ included\ from\ %f:%l

(从最新的Vim源代码中提取的设置,来自文件src/option.h

4

:make! 不会跳转到第一个结果。


2
那并不是实际的问题,尽管那是我使用的解决办法。 - sehe
但我想要跳到第一个结果!谢谢你指出来,我一直想找这个,但就是找不到足够的时间...主要是我想跳到第一个错误/警告(并修复它)... - stefanB
1
+1,因为你向我展示了我从未有时间寻找的选项 :) - stefanB

1

问题出在针对最新版本的gcc所需的错误格式有些微不同。

我记得在C++休息室(聊天室)里提到过这个问题并发布了一个据说更有效的错误格式。 我还没有测试它是否有效

  • https://chat.stackoverflow.com/search?q=errorformat&room=10

     errorformat=%*[^"]"%f"%*\D%l: %m,"%f"%*\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GInfile included from %f:%l:%c:,%-GIn file included from %f:%l:%c\,,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,"%f"\, line %l%*\D%c%*[^ ] %m,%D%*\a[%*\d]: Entering directory `%f',%X%*\a[%*\d]: Leaving directory `%f',%D%*\a: Entering directory `%f',%X%*\a: Leaving directory `%f',%DMaking %*\a in %f,%f|%l| %m
    

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接