Saturday, February 27, 2010

Re: Close all buffers, stay open

On Saturday 27 February 2010 07:11:05 pm Tim Johnson wrote:

> For my purposes, it would be great if I could close all
> buffers, but keep vim open.
>
> I note ':on', but that just closes all windows, buffers
> remain.
>
> The end game is:
> Close all buffers, load a different session.
>

one thing i like to [easily] do is close all but the current
buffer -- to this end i have

nnoremap <Leader>dd :call ClearBuffers()<CR>

function! ClearBuffers()
let i = 1
let dc = 0
while i <= bufnr("$")
if buflisted(i) && i != bufnr("")
exe "bdelete" i
let dc += 1
endif
let i += 1
endwhile
echo 'buffers deleted:' dc
endfunction

in my .vimrc -- you could easily modify it (by removing the

"&& i != bufnr("")"

) to delete even the current buffer

hth,

sc

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment