I use VIM in the development of C++ projects and configured a compile shortcurt as follows
map <F4> :w<CR> :set makeprg=make<CR> :make <CR>:cw 4<CR>
which builds my project and shows the quickfix window in case there are any errors.
However this will always make vim open the file containing the first error in my current buffer, which is annoying when the error is not logically caused by the line indicated by the compiler but some other piece of code in the file that is currently openened. Can I prevent VIM from switching the currently openened file when jumping to an error (i.e. go to first error only if is contained in the current file, otherwise just open quickfix window). In addition: can I prevent jumping to the first error at all (again: just open quickfix window)
To prevent the
:makecommand from jumping to the first error, call it with!modifier,See
:help :make, item 7.