Loading ...
Sorry, an error occurred while loading the content.

Re: Hidden buffers

Expand Messages
  • Gary Johnson
    ... How about using :redir to capture the output of :ls and parsing the result? Regards, Gary -- -- You received this message from the vim_use maillist. Do
    Message 1 of 7 , Apr 7, 2013
    • 0 Attachment
      On 2013-04-06, LCD 47 wrote:
      > Given a buffer number, is it possible to find out (in Vimscript)
      > whether the corresponding buffer is hidden or not?

      How about using :redir to capture the output of :ls and parsing the
      result?

      Regards,
      Gary

      --
      --
      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 vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • LCD 47
      On 7 April 2013, Marcin Szamotulski wrote: [...] ... [...] ... Aha, this works fine, thank you! ... This works too, using bufwinnr()
      Message 2 of 7 , Apr 7, 2013
      • 0 Attachment
        On 7 April 2013, Marcin Szamotulski <mszamot@...> 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 <garyjohn@...> 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 vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      Your message has been successfully submitted and would be delivered to recipients shortly.