Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I close vim if the only window left open is a quickfix window? #38

Open
axiaoxin opened this issue Apr 23, 2015 · 5 comments
Open

Comments

@axiaoxin
Copy link

I try to add this

autocmd bufenter * if (winnr("$") == 1 && exists("b:loaded_flake8_ftplugin") && b:loaded_flake8_ftplugin == "primary") | q | endif

but it not work

@khadiwala
Copy link

I wanted something close to what you wanted - on :w I wanted a quick fix, but on :wq I did not. Here's my hack for that in case it helps:

autocmd BufWritePost *.py call Flake8()
function NoShow()
    let g:flake8_show_quickfix=0
    wq
endfunction
autocmd FileType python cmap wq call NoShow()

@garywahaha
Copy link

Here is what I am using right now:
autocmd FileType python cnoreabbrev <expr> q winnr("$") > 1 && getcmdtype() == ":" && getcmdline() == 'q' ? 'ccl <BAR> q' : 'q'
It will automatically close the quick fix window if there is one.
Combining with @khadiwala answer is enough for my usage.

@axiaoxin
Copy link
Author

@khadiwala @garywahaha cool,
but I test @khadiwala way, :q and :x not work.
and @garywahaha way :wq and x not work

@garywahaha
Copy link

@axiaoxin In that case I think you may try

function NoShow()
    let g:flake8_show_quickfix=0
    wq  
endfunction
autocmd FileType python cnoreabbrev <expr> wq getcmdtype() == ":" && getcmdline() == 'wq' ? 'call NoShow()' : 'wq'
autocmd FileType python cnoreabbrev <expr> q winnr("$") > 1 && getcmdtype() == ":" && getcmdline() == 'q' ? 'ccl <BAR> q' : 'q'
autocmd FileType python cnoreabbrev <expr> x winnr("$") > 1 && getcmdtype() == ":" && getcmdline() == 'x' ? 'ccl <BAR> x' : 'x'

@josecastillolema
Copy link

A more generic solution not specific for Python nor Flake8:

" Close vim if the only window left is quickfix
aug QFClose
  au!
  au WinEnter * if winnr('$') == 1 && &buftype == "quickfix"|q|endif
aug END

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants