Monday, May 2, 2011

Re: how to get list of not displayed (hidden or unloaded) buffers

Reply to message «how to get list of not displayed (hidden or unloaded)
buffers»,
sent 22:50:57 02 May 2011, Monday
by Sergey Vakulenko:

Try the following code:
function s:BufHidden(bufnr)
return empty(filter(map(range(1, tabpagenr('$')),
\'tabpagebuflist(v:val)'),
\'index(v:val, a:bufnr)!=-1'))
endfunction

Original message:
> Hello
> I want to know, how i can identify buffer, if it's displayed on screen
> or not.
>
> For example i open buffer 'option.c', then open buffer 'file2.txt' in
> same window/tab.
> 'option.c' became hidden:
>
> ----
>
> :buffers
>
> 25 #h "d:\workspace\sources\gvim_73\vim-7.3\vim73\src\option.c"
> line 1
> 26 %a "file2.txt" line 1
> Press ENTER or type command to continue
> ----
>
> i need something like this:
>
> for buffer_ in bufnr('$'))
> if buffer_ == "not displayed"
> do .....
> endif
> endfor
>
>
>
>
> thanks in advance
> Sergey V.

No comments: