Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing :make in VIM from going to a warning

I have a warning I can not easily remove from my build, every time i run ":make" from inside vim the quickfix takes me to some header file I don't care about. How can I prevent VIM from doing this and only showing me warnings and errors I do care about?

like image 859
Jon Clegg Avatar asked Mar 19 '09 19:03

Jon Clegg


1 Answers

As Luc Hermite said, it is possible to ignore warnings using 'errorformat'option. Adjusting this option is a little bit complicated; it may be helpful to check $VIMRUNTIME/compiler for some examples.

When working with avr-gcc and C++ some annoying warnings like this

tests.cpp:492: warning: only initialized variables can be placed into program memory area

shows up, and it is likely to be result of a compiler fault.

To avoid that this warnings being displayed on quickfix window I've add this to ~/.vimrc:

compiler gcc
set errorformat^=%-G%f:%l:\ %tarning:\ only\ initialized\ varia
            \bles\ can\ be\ placed\ into\ program\ memory\ area

The %-G can be used to specify patterns to be ignored. The ^= in set errorformat^=... is used to prepend the ignored warning pattern to 'errorformat' -- using += (set errorformat+=...) would append to the option and wouldn't work, as 'errorformat' is a list of formats and the first one that matches is used, thus the "normal" warning pattern would apply instead.

Maybe you could adapt these settings for your environment.

like image 65
mMontu Avatar answered Oct 21 '22 14:10

mMontu