0

I am creating a plugin in vim that involves having a sidebar, within which you can switch between several different buffers with different functions. I am wondering how to hide these buffers from the buffer list (when you type :buffers or :ls) so as not to clutter the buffer list.

0
1

You might try making the buffer unlisted with :set nobl (see :h 'buflisted'). This is a buffer local setting so it only affects the current buffer.

Unlisted buffers don't show up with :ls by default (see below).

Not sure if this will work with what you have in mind for your plugin as you didn't provide a lot of details. But the basic requirement would be fulfilled.

You can list such buffers by adding ! to :ls or by adding u, i.e. :ls! or :ls u. The latter shows only unlisted buffers. You can edit an unlisted buffer by switching to it using :b # where # is its buffer number. From there you can revert to listed status with :set bl.

9
  • with set hidden, :ls h is kind of like what OP wants maybe? – Mass Oct 21 '20 at 23:32
  • @Mass I'm not sure. Would that be flexible enough to work for both users that don't have 'hidden' set as a rule and those that do (myself included)? Maybe I'm not understanding the advantage vs unlisted... – B Layer Oct 21 '20 at 23:41
  • (I'm assuming OP is creating a plugin for public use.) – B Layer Oct 21 '20 at 23:42
  • True. I think though, if I were creating a plugin, I would use a for loop and bufwinid() – Mass Oct 22 '20 at 0:15
  • 1
    @BLayer Thanks for the advice! Unfortunately, as this is my first post on the vim stack exchange I do not have enough points to vote, but I have accepted your answer. – Prismavoid Oct 22 '20 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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