> From: Charles E Campbell Jr [mailto:[EMAIL PROTECTED] 
> 
> David Howland wrote:
> 
> > A.J.Mechelynck wrote:
> >
> >> You mean if the buffer is displayed it would do nothing?
> >
> > No.  Delete the buffer, but keep the window open.
> >
> > I often find myself in this situation:
> > - Split window, two buffers open.
> > - Open a new file, look at it, then want to close it.
> > - i would expect to ":bd" to delete the current buffer, leaving the 
> > remaining two open, one for each window.  But for some 
> reason, it also 
> > removes my split.  Why should deleting a buffer change how 
> I have my 
> > splits set up?
> 
> Because a window must always have a buffer to display.  See
> 
> "Deleting a buffer without changing your window layout"
> http://vim.sourceforge.net/tips/tip.php?tip_id=622

This is my take at this (sorry, no comments):

function! WipeoutBuffer()
    let w_cur = winnr()
    let b_cur = winbufnr(0)
    bnext
    let b_new = winbufnr(0)
    if b_new == b_cur
        enew
        let b_new = winbufnr(0)
    endif
    windo if winbufnr(0) == b_cur | execute b_new . 'b' | endif
    execute w_cur . 'wincmd w'
    execute 'bwipeout! ' . b_cur
endfun

Reply via email to