On 08/04/09 17:15, bill lam wrote:
> On Wed, 08 Apr 2009, Tim Chase wrote:
>> Does this work for you?
>>
>> let cur=bufnr('%') | bufdo if bufnr('%') != cur | bd! | endif
>
> Thanks it works, I prefer bw to bd.
>
> On second thought, my requirement seemed faulty in that all buffers
> except the current should already be written otherwise it can
> not be switched, Is this correct?
>
> If the current buffer has unsaved modification, Tim's function gives
> warning and aborted. Why are such warning when it is supposed to delete
> other_ buffers? Can this be improve>
>
The following (untested) does it without changing buffers:
function ClearBuffers(wipeout)
" usage:
" call ClearBuffers(0) to delete all buffers except the current one
" call ClearBuffers(1) to wipe them out
let i=1
while i <= bufnr("$")
if bufexists(i) && i != bufnr("")
exe (a:wipeout? "bwipeout!" : "bdelete!") i
endif
let i += 1
endwhile
endfunction
Best regards,
Tony.
--
"Beware of bugs in the above code; I have only proved
it correct, not tried it." -- Donald Knuth
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---