Permalink
Browse files

Version 1.1: fixed some bugs

  • Loading branch information...
1 parent a30bf5c commit 1fd0382dd299b9feb343b7960f6977de402b0929 Ben Booth committed with vim-scripts Dec 18, 2007
Showing with 9 additions and 13 deletions.
  1. +9 −13 plugin/kwbdi.vim
View
@@ -19,33 +19,29 @@ noremap <unique> <script> <Plug>Kwbd :call <SID>Kwbd(1)<CR>:<BS>
"delete the buffer; keep windows
function <SID>Kwbd(kwbdStage)
if(a:kwbdStage == 1)
- " count the number of buffers in the buffer list,
- " and find an empty buffer if it exists
- let g:kwbdNumBuffers=0
+ let g:kwbdBufNum = bufnr("%")
+ let g:kwbdWinNum = winnr()
let g:kwbdEmptyBuffer=0
+
+ " count the number of buffers in the buffer list
+ let g:kwbdNumBuffers=0
for i in range(1,bufnr('$'))
- if (strlen(bufname(i))==0)
- let g:kwbdEmptyBuffer=i
- endif
if (getbufvar(i, '&buflisted') == 1 && getbufvar(i, '&modifiable') == 1)
let g:kwbdNumBuffers = g:kwbdNumBuffers + 1
endif
endfor
- let g:kwbdBufNum = bufnr("%")
- let g:kwbdWinNum = winnr()
+ " switch all windows to another buffer
windo call <SID>Kwbd(2)
- if (getbufvar(bufnr('%'), '&modifiable') != 1)
- return
- endif
-
if (getbufvar(g:kwbdBufNum, '&buflisted') == 1)
execute "bd! " . g:kwbdBufNum . ""
endif
- execute "normal " . g:kwbdWinNum . ""
+ " go back to the original window
+ execute "normal " . g:kwbdWinNum . "\<c-w>\<c-w>"
else
+ " This part will be run for each window
if(bufnr("%") == g:kwbdBufNum)
let prevbufvar = bufnr("#")
if(g:kwbdNumBuffers <= 1 && g:kwbdEmptyBuffer != 0)

0 comments on commit 1fd0382

Please sign in to comment.