vim-flake8 icon indicating copy to clipboard operation
vim-flake8 copied to clipboard

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

Open axiaoxin opened this issue 10 years ago • 5 comments

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

axiaoxin avatar Apr 23 '15 07:04 axiaoxin

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()

khadiwala avatar Jul 06 '15 01:07 khadiwala

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.

garywahaha avatar Mar 11 '16 08:03 garywahaha

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

axiaoxin avatar Mar 11 '16 09:03 axiaoxin

@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'

garywahaha avatar Mar 11 '16 09:03 garywahaha

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

josecastillolema avatar Nov 24 '23 10:11 josecastillolema