Skip to content

Instantly share code, notes, and snippets.

@runningskull
Created March 21, 2011 02:33
Show Gist options
  • Save runningskull/878930 to your computer and use it in GitHub Desktop.
Save runningskull/878930 to your computer and use it in GitHub Desktop.
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
command! BD call Kwbd(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment