Created
June 6, 2012 17:17
-
-
Save kenichi/2883384 to your computer and use it in GitHub Desktop.
kill buffer, keep window (vim)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" delete buffer, keep window | |
function Kwbd(kwbdStage) | |
if(a:kwbdStage == 1) | |
let g:kwbdBufNum = bufnr("%") | |
let g:kwbdWinNum = winnr() | |
windo call Kwbd(2) | |
execute "bd! " . g:kwbdBufNum | |
execute "normal " . g:kwbdWinNum . "" | |
else | |
if(bufnr("%") == g:kwbdBufNum) | |
let prevbufvar = bufnr("#") | |
if(prevbufvar > 0 && buflisted(prevbufvar) && prevbufvar != g:kwbdBufNum) | |
b # | |
else | |
bn | |
endif | |
endif | |
endif | |
endfunction | |
map <C-w><C-k> :call Kwbd(1)<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment