On 08:18 Sun 07 Apr     , Marcin Szamotulski wrote:
> On 19:23 Sat 06 Apr     , tooth pik wrote:
> > On Sat, Apr 06, 2013 at 10:48:37PM +0300, LCD 47 wrote:
> > >    Given a buffer number, is it possible to find out (in Vimscript)
> > > whether the corresponding buffer is hidden or not?
> > 
> > you can change to said buffer with the buffer command
> > 
> >     :buffer <bufno>
> > 
> > then you can test &bufhidden for a null value or any of its other
> > possibilities (anything other than null will mean it's hidden)
> > 
> >     if &bufhidden == ""
> >         do unhidden stuff
> >     else
> >         do hidden stuff
> >     endif
> > 
> > this help at all?
> > 
> > -- 
> > -- 
> > 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 because you are subscribed to the Google Groups 
> > "vim_use" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to [email protected].
> > For more options, visit https://groups.google.com/groups/opt_out.
> > 
> 
> You can also get the value with
> 
>     let bufhidden =  getbufvar(bufnr, '&bufhidden')
> 
> See
> :help getbufvar
> :help :let-&
> 
> Best,
> Marcin

Actually this also will not work since bufhidden is not reset for hidden
buffers - it works in a different way, it rather instructs vim what to
do with buffers which become hidden.

The solution might be a loop over tabpages and checking if a buffer is
associated with one of them.  The following function will test if bufnr
is associated with one of tabpages:

fun! BufInTab(bufnr)
    for tabnr in range(1,tabpaggenr('$'))
        if index(tabpagebuflist(tabnr), a:bufnr) != -1
            return 1
        endfi
    endfor
    return 0
endfun

If you just want to test if the buffer is not shown just in the current
tab page you can use winbufnr(), it return -1 if the buffer has not
associated window.

Best,
Marcin

-- 
-- 
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 because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to