Changed 'Q' to intelligently close window or kill buffer if it's the last one

This commit is contained in:
yan
2011-12-22 11:55:18 -08:00
parent 3eec4c39e6
commit 476e72ba63
3 changed files with 13 additions and 7 deletions

View File

@@ -111,11 +111,6 @@ map <silent> <D-0> :tabn 0<cr>
nnoremap <silent> vv <C-w>v
nnoremap <silent> ss <C-w>s
" Use Q to kill a buffer
nnoremap <silent> Q :bw<CR>
" Remap \Q to close a window (leave buffer open in memory)
nnoremap <silent> <Leader>Q <C-w>c
"open the taglist (method browser) using ,t
nnoremap <silent> ,T :TlistToggle<CR>

View File

@@ -0,0 +1,12 @@
" Use Q to intelligently close a window
" (if there are multiple windows into the same buffer)
" or kill the buffer entirely if it's the last window looking into that buffer
function! CloseWindowOrKillBuffer()
if(bufwinnr('%')) > 1
wincmd c
else
bdelete
endif
endfunction
nnoremap <silent> Q :call CloseWindowOrKillBuffer()<CR>