On 7 April 2013, Marcin Szamotulski <[email protected]> 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?

[...]
> 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

    Aha, this works fine, thank you!

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

    This works too, using bufwinnr() (winbufnr() returns the buffer in
window, bufwinnr() gets the window of the buffer).  It's exactly what I
need.

On 7 April 2013, Gary Johnson <[email protected]> wrote:
> How about using :redir to capture the output of :ls and parsing the
> result?

    That was the last resort option, it's really ugly, and I'm glad
there's a better solution. :) But thank you for answering nonetheless.

    /lcd

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