0

As title. I want to check that a buffer is not shown in any tabs. How to do so?

0

2 Answers 2

2

Buffer is called "hidden" if it's

  1. Loaded
  2. Not shown in any window
:echo bufloaded(N) && win_findbuf(N)->empty()

or

:echo bufexists(N) && getbufinfo(N)[0].hidden
2
  • Additional one: Do you know the api to do the same in Lua(for NeoVim)? While your current one is really helpful since now I really understand hidden mean and I can still use NeoVim's API to write VimScript. Commented Jan 10, 2022 at 18:05
  • @job_start Neovim API is documented in :h api.txt. AFAIR, there's none.
    – Matt
    Commented Jan 10, 2022 at 18:21
0

FYI: You can use the following APIs in Lua:

local is_hidden_buffer = vim.api.nvim_buf_is_loaded(buf)
                         and vim.api.nvim_buf_get_option(buf, 'buflisted')

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.