Do not change the current buffer when using the vim quick settings window

I am using VIM in C ++ project development and configured the shortcurt compiler as follows

map <F4> :w<CR> :set makeprg=make<CR> :make <CR>:cw 4<CR> 

which builds my project and shows a quick fix window in case of any errors.

However, this will always force vim to 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 by some other piece of code in the file that is currently openened. Can I prevent VIM from switching the file with open files when switching to an error (for example, go to the first error only if it is contained in the current file, otherwise the quick delete window will simply open). In addition: can I prevent switching to the first error at all (again: just open the quick delete window)

+7
source share
2 answers

To prevent the :make from moving to the first error, call it with ! ,

 :make! 

See :help :make , paragraph 7.

+10
source

Besides using make! (with interference), see also 'switchbuf' .

You can use set switchbuf=split to always use the new split when opening a file from quickfix.

Also check that you did not set switchbuf=useopen , which can lead to unexpected window / buffer changes when viewing the quick delete list.

+4
source

All Articles