Wiki: Dont Close My Window


Challenge

When you have several windows laid out, and you use :bd, the window containing the buffer is closed; make it not do that. The behavior should be the same as using :bd when there is only one window.

Required

Bonus


Solutions

" :Bd <buffernum> - by FallingCow
command! -bang -nargs=? Bd call <Sid>BDel('<bang>', <args>)
function! <Sid>BDel(bang, ...)
  let curbuf = (a:0 ? a:1 : winbufnr(0))
  if (winbufnr(2) != -1)

    " Find buffer to move to
    let otherbuf = 1
    while otherbuf <= bufnr('$') && (!buflisted(otherbuf) || !getbufvar(otherbuf, '&modifiable') || otherbuf == curbuf)
      let otherbuf = otherbuf + 1
    endwhile
    if otherbuf > bufnr('$')
      enew
      let otherbuf = winbufnr(0)
    endif

    " Loop through windows looking for buffer to be removed
    while bufwinnr(curbuf) != -1
      exe "norm " . (bufwinnr(curbuf)) . "\<C-W>\<C-W>"
      exe "b" . otherbuf
    endwhile
  endif

  " Delete old buffer
  exe "bd" . a:bang . " " . curbuf
endfunction

<small>P? anale sex anal teen amatuer anal anal stretching analverkehr tipps slut anal

foot fetish tgp smelly feet fetish femdom feet feet fetish video foot fetish club lesbian foot fetish

webcam gay webcams gay webcams gay webcam webcam perso gay gay hidden cams

latex suit latex love doll latex fashion fetisch de fetisch queen fetisch galerie

bisexual rape rape adult rape survivor rape passwords oilseed rape to rape

|?

ifriends teens on webcams live webcam adult public web cams sex cams webcam com

jerking off pics jerk off buddies ways to jerk off ways to jerk off jerk me off girls jerking off

|?

</small>


Copyright © 2007 RobertMelton.com