Permalink
Browse files

Auto quit Vim when actual files are closed

  • Loading branch information...
yous committed Nov 24, 2014
1 parent d0e0d83 commit 735976604471bb6186d3867a30c421c839ad3ad4
Showing with 23 additions and 15 deletions.
  1. +23 −15 vimrc
38 vimrc
@@ -298,22 +298,35 @@ function SetHelpMapping()
nnoremap <buffer> q :q<CR>
endfunction
autocmd FileType help call SetHelpMapping()
autocmd BufEnter *
\ if winnr('$') == 1 &&
\ getbufvar(winbufnr(winnr()), '&buftype') == 'help' |
\ q |
\ endif

" Quickfix
function SetQuickfixMapping()
nnoremap <buffer> q :ccl<CR>
endfunction
autocmd FileType qf call SetQuickfixMapping()
autocmd BufEnter *
\ if winnr('$') == 1 &&
\ getbufvar(winbufnr(winnr()), '&buftype') == 'quickfix' |
\ q |
\ endif

" Auto quit Vim when actual files are closed
function! CheckLeftBuffers()
if tabpagenr('$') == 1
let i = 1
while i <= winnr('$')
if getbufvar(winbufnr(i), '&buftype') == 'help' ||
\ getbufvar(winbufnr(i), '&buftype') == 'quickfix' ||
\ exists('t:NERDTreeBufName') &&
\ bufname(winbufnr(i)) == t:NERDTreeBufName ||
\ bufname(winbufnr(i)) == '__Tag_List__'
let i += 1
else
break
endif
endwhile
if i == winnr('$') + 1
qall
endif
unlet i
endif
endfunction
autocmd BufEnter * call CheckLeftBuffers()

" Search regex
nnoremap / /\v
@@ -474,11 +487,6 @@ autocmd VimEnter *
\ if (s:open_sidebar) |
\ call OpenSidebar() |
\ endif
autocmd BufEnter *
\ if winnr('$') == 1 &&
\ exists('b:NERDTreeType') && b:NERDTreeType == 'primary' |
\ q |
\ endif

" ConqueTerm
let g:ConqueTerm_InsertOnEnter = 1

0 comments on commit 7359766

Please sign in to comment.