Saturday, March 26, 2011

Re: close all unvisible buffers

Hi Bob.

Thanks for your response.

10x

2011/3/25 Bob Hiestand <bob.hiestand@gmail.com>
On Thu, Mar 24, 2011 at 4:07 AM, Caesarmv <caesarmv@gmail.com> wrote:

> This is my first message. Can you see me?

Yes.

> My question is: how to close all unvisible buffers?
> For example: I have 5 tabs opened (5 visible buffers) and many unvisible
> buffers (I am seeing with :ls command).

You could define a function like the following:

function! CloseHiddenBuffers()
       let lastBuffer = bufnr('$')
       let currentBuffer = 1
       while currentBuffer <= lastBuffer
               if bufexists(currentBuffer) && buflisted(currentBuffer) &&
bufwinnr(currentBuffer) < 0
                       execute 'bdelete' currentBuffer
               endif
               let currentBuffer = currentBuffer + 1
       endwhile
endfunction

.. and map that to a useful key sequence.

--
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

--
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: