Quickfix in VIM

Quickfix in VIM

One of the most fascinating things with the VIM editor is that you find new features every day, even after many years of heavy usage.

Quickfix is one of those features.

Quickfix parse your compiler-output and let you easy navigate to the concerned lines with errors and/or warnings. Great hue?

How does it work?

The builtin command is (surprisingly) make. Just do :make (without bang character!)

make will do whatever the makeprg variable is set to. By default makeprg is set to ... make (as in GNU Make, not the builtin command).

For example, if you are programming ruby, you may set makeprg to "ruby -c %".

I compile the Linux kernel a few times a day, so I usually set the the variable like this:

set makeprg=make\ ARCH=arm\ CROSS_COMPILE=arm-none-linux-gnueabi-\ uImage

Ok, the stuff is compiling, now what?

Typical commands you use is::
:copen - opens quick fix window as a new buffer :cnext - or :cn, jump to next error :cprevious - or :cp, jump to previous error :cclose - close the quick fix window

And the best of all:

:cwindow - or :cw, open quickfix window if there are errors and close it if there are not.