Completely exit location list (lcl) created by Syntastic as well the main buffer when using :q, :q! or :wq! in VIM
I'm开发者_运维知识库 using Syntastic plugin. I have some files with some errors (Warnings) that I can't change. When I have a file opened with error messages, and I quit the file(buffer) pressing :q, the error messages are still visible(another buffer), so I have to press :q twice to completely exit when editing a file.
So, how do I press :q just once with a file with a buffer containing my file and another buffer (location list) containing Syntastic errors? I've searched a little bit and the command to close the location list is :lcl.
When I exit a buffer with :q, if the location list for that buffer is active, I want to close it with the location list within, calling :lcl. I'm reading some autocmd BufLeave
and BufWinLeave
and trying to create a mapping for this, but I cant know the difference between the two. Can someone help me?
Remembering, :w, :q, :q!, :wq
should all work as intended.
As lcl work even if there is no error window you can map q to lcl and q
cnoremap q<cr> \|lcl\|q<cr>
As suggested an abbreviation seems better
cabbrev q lcl\|q
(note the \ before |, without it does the abbreviation then quit )
I realize this question is old and that the answer was accepted sometime ago. I tried using the accepted answer but it does not seem to work any more.
I did however find a workaround from this question, should others run in to this.
Basically, use a script to check if there are any other remaining windows open and if the last remaining window is a location-list, quit.
:autocmd WinEnter * if &buftype ==# 'quickfix' && winnr('$') == 1 | quit | endif
I think this may not be ideal but works well enough in the meantime.
精彩评论