Reputation: 38593
Is there a way to distinguish between hidden and active buffers in Vim?
I need to determine if a buffer is active in a window so I can toggle it.
Tried bufloaded
, bufexists
and buflisted
but they all return 1 for both active and hidden buffers.
(I have set hidden
and set bufhidden=hide
in my vimrc)
Upvotes: 5
Views: 1597
Reputation: 41
You can use :ls to see a list of all buffers. Buffers with a 'h' next to the buffer number are hidden. 'a' indicates active buffer.
Upvotes: 4
Reputation: 7946
Use bufwinnr()
to check if a buffer is open in a window. The result is -1
if it is not.
Upvotes: 9