Hem*_*mer 8 vim buffer makefile
我有在Vim的设置,我可以用我的编译C/C++代码:make
和编译错误在quickfix窗口使用下列行自动显示(从Vim的维基)我./vimrc
:
" Automatically open, but do not go to (if there are errors) the quickfix /
" location list window, or close it when is has become empty.
"
" Note: Must allow nesting of autocmds to enable any customizations for quickfix
" buffers.
" Note: Normally, :cwindow jumps to the quickfix window if the command opens it
" (but not if it's already open). However, as part of the autocmd, this doesn't
" seem to happen.
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow
Run Code Online (Sandbox Code Playgroud)
现在,如果.cpp文件中存在错误,则此设置很有效,因为正确解析了make的输出:
$ make
g++ -c -o IsingMain.o IsingMain.cpp
g++ -c -o LatticeModel.o LatticeModel.cpp
LatticeModel.cpp: In member function ‘void LatticeModel::initialiseSystem()’:
LatticeModel.cpp:18:25: error: ‘sirand’ was not declared in this scope
Run Code Online (Sandbox Code Playgroud)
即vim正确切换到LatticeModel.cpp
.
但是如果错误在头文件中,则make输出被误解,并且vim切换/创建一个make
名为" In file included from IsingMain.cpp
" 的新缓冲区(对于下面的示例输出),显然错误地假设这是带错误的文件(实际上)错误发生在LatticeModel.h中:
$ make
g++ -c -o IsingMain.o IsingMain.cpp
In file included from IsingMain.cpp:2:0:
LatticeModel.h:31:5: error: ‘Zvoid’ does not name a type
Run Code Online (Sandbox Code Playgroud)
从命令行运行make非常有效,这只是quickfix误读它输出的问题.任何帮助非常感谢,让我知道这是否有任何困惑.谢谢
编辑:它似乎与错误格式错误(如此线程中所述 )有关.
编辑2:通过使用此技术忽略以"在文件中包含"开头的make输出行找到的临时修复.
虽然我还没有找到合适的解决方案,但此处建议的解决方法是:http://groups.google.com/group/vim_dev/msg/ed4f258f5b4b9749 似乎暂时有效.
set errorformat^=%-GIn\ file\ included\ %.%#
Run Code Online (Sandbox Code Playgroud)
编辑:另见Vim尝试跳转到不存在的文件后:make