Nilesh Bhave
Nilesh Bhave

Reputation: 301

Syntastic close error window and original file window

I've installed Syntastic from GitHub and I'm trying to use Syntastic for checking perl syntax errors (and planning to use for Python in a short while). When I use ':quit' or ':q', only original file window closes. The error window does not close. Below is snip from my .vimrc file :

execute pathogen#infect()  
set statusline+=%#warningmsg#  
set statusline+=%{SyntasticStatuslineFlag()}  
set statusline+=%*  
let g:syntastic_perl_checkers = ['perl']  
let g:syntastic_python_checkers = ['pylint']  
let g:syntastic_enable_perl_checker = 1  
let g:syntastic_always_populate_loc_list = 1  
let g:syntastic_auto_loc_list = 1  
let g:syntastic_check_on_open = 1

Since I'm very new to vim scripting, I would like to know how to close both windows, error window and original file window, when I use ':quit' or ':q' while original file window is active.

Upvotes: 6

Views: 2160

Answers (3)

PokerFace
PokerFace

Reputation: 801

According to Syntastic help, the command to close Syntastic error window is:

:SyntasticReset

Upvotes: 3

sunjerry
sunjerry

Reputation: 51

Try the below command:

:lclose

Upvotes: 4

Ingo Karkat
Ingo Karkat

Reputation: 172598

That's the normal Vim behavior; it has nothing to do with Syntastic. The quickfix or location list windows may contain references to other files, so it is not certain that you want to completely leave Vim when quitting from the originating window.

The simplest solution is using :qa (quit all) instead of :q. As the error window doesn't contain unpersisted changes, this is safe and doesn't require a confirmation.

If you are annoyed by having to think about this, you can use Vim's scripting capabilities to change its behavior:

:autocmd WinEnter * if &buftype ==# 'quickfix' && winnr('$') == 1 | quit | endif

This checks on each change of window whether there's only one window left, and if that one is a quickfix / location list, it quits Vim.

Upvotes: 5

Related Questions