Using Vim: make with quickfix finishes creating a new file when there is an error in the header

I have a setup with Vim where I can compile my C / C ++ code with :make , and compilation errors are automatically displayed in the quick fix window using the following lines (from the Vim wiki) in my ./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 already open). However, as part of the autocmd, this doesn't " seem to happen. autocmd QuickFixCmdPost [^l]* nested cwindow autocmd QuickFixCmdPost l* nested lwindow 

Now this setting works well if there is an error in the .cpp file , since the output from make is parsed correctly:

 $ 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 

i.e. vim correctly switches to LatticeModel.cpp .


However, if the error is in the header file , make output is not interpreted correctly, and vim switches / creates a new buffer (for the following make output example) with the name " In file included from IsingMain.cpp ", obviously mistakenly believing that it is an error file ( actually the error is in 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 

Running make from the command line works fine, it's just a problem when quickfix doesn't read its output correctly. Any help is much appreciated, let me know if any part of this is confusing. Thanks

EDIT . This seems to be due to the wrong errorformat format (as described in this thread .)

EDIT 2 : A temporary fix is ​​found ignoring the make output line that begins with "In the file included from" using this method .

+8
vim makefile buffer
source share
1 answer

So far I have not found the right solution, the workaround offered here: http://groups.google.com/group/vim_dev/msg/ed4f258f5b4b9749 seems to work now.

 set errorformat^=%-GIn\ file\ included\ %.%# 

EDIT : see also Vim tries to go to a nonexistent file after: make

+5
source share

All Articles