Quantcast

close all unvisible buffers

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

close all unvisible buffers

Caesarmv
Hi folks.

This is my first message. Can you see me?


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


10x

--
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: close all unvisible buffers

Bob Hiestand
On Thu, Mar 24, 2011 at 4:07 AM, Caesarmv <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: close all unvisible buffers

Caesarmv
Hi Bob.

Thanks for your response.

10x

2011/3/25 Bob Hiestand <[hidden email]>
On Thu, Mar 24, 2011 at 4:07 AM, Caesarmv <[hidden email]> 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
Loading...