Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distinguish between hidden and active buffers in Vim

Tags:

vim

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)

like image 645
mihai Avatar asked Dec 27 '22 02:12

mihai


2 Answers

Use bufwinnr() to check if a buffer is open in a window. The result is -1 if it is not.

like image 112
Codie CodeMonkey Avatar answered Feb 06 '23 23:02

Codie CodeMonkey


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.

like image 32
ikelkar Avatar answered Feb 06 '23 23:02

ikelkar