Both :ls and :buffers display a list with buffer information, giving indicators for each buffer. For example, # means the alternate buffer, and % means the current buffer. The meaning of each indicator is explained in :h :ls or :h :buffers. For a and h, it says:

    a     an active buffer: it is loaded and visible
    h     a hidden buffer: It is loaded, but currently not
              displayed in a window |hidden-buffer|

From this description, I would imagine that every buffer must be either active or hidden, since every buffer must be either shown or not shown. However, I often encounter buffers that don't have any of the two indicators. For example, buffer 8 in my current :ls list doesn't have any of the two:

  2 #h   "Silent commands.wiki"         line 35
  8      "~/repos/dotvim/vimrc"         line 0
 11 %a   "~/repos/wiki/diary/2021-03-20.wiki" line 47

How is this possible? Am I not understanding something?


1 Answer 1


You'll find more details under :h active-buffer and the sections that follow...

active:   The buffer is displayed in a window.  If there is a file for this
      buffer, it has been read into the buffer.

hidden:   The buffer is not displayed.  If there is a file for this buffer, it
      has been read into the buffer.  Otherwise it's the same as an active
      buffer, you just can't see it.

inactive: The buffer is not displayed and does not contain anything.

So you're wondering about the the "inactive" windows. This table may help.

state       displayed   loaded      ":buffers" 
             in window               shows      
active        yes        yes          'a'
hidden        no         yes          'h'
inactive      no         no       ' '

Here's an easy way to produce one:

  1. Start vim with a file
  2. Tell vim to add another file to the buffer list: :badd /some/other/file
  3. :ls

:badd does not load the file it just queues it up to be loaded when you switch to it with, for example, :bnext.

It can't be active since it's not visible. It can't be active or hidden since it hasn't been loaded yet.

  • Thank you for the extremely quick reply. Is there a way to programmatically determine whether a buffer is active, hidden or inactive? I can distinguish between active and hidden/inactive with bufwinnr(), since this function returns -1 when the buffer is not active. But I don't know any way to distinguish hidden from inactive.
    – mgarort
    Commented Mar 20, 2021 at 4:07
  • 1
    I know you can test whether a buffer is loaded with :echo bufloaded("/some/file"). There's also buflisted() and bufexists(). Between all those you can get a pretty clear picture, I think. I'll see if I can narrow the focus down even more than that. Oh, yeah, there's also getbufinfo() which returns a whole bunch of info....that may be the ticket.
    – B Layer
    Commented Mar 20, 2021 at 4:12
  • 1
    Yeah, look into getbufinfo()...it has the same info as the other three I listed and a lot more.
    – B Layer
    Commented Mar 20, 2021 at 4:16
  • Thank you. I think that function does the job already, no need to narrow it down more. You can first check whether a buffer is visible with bufwinnr(). If it is not, then it must be either hidden or not loaded. Then you can do a second check with bufloaded(). If it is loaded, it is hidden, and if it is not loaded, it is not loaded. Thanks!
    – mgarort
    Commented Mar 20, 2021 at 4:16
  • 1
    No problem. getbufinfo() will get you the info you want with a single func call, FYI.
    – B Layer
    Commented Mar 20, 2021 at 4:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.