0

When I use :ls in Vim, I can see the list of open buffers. But when I open a buffer for documentation, for example :h help, I cannot see an entry for it in the :ls list, even if I open it by :tab h help. Why we cannot see that? Is there a way to include this buffer in the list?

2 Answers 2

5

I think the intention was, that using :ls helps you navigate your buffers on which you are actively working. If you open the help pages and browse between a few topics you can easily have 10s of different help buffers opened, which means the output of :ls might be hard to read and hard to find the correct buffer.

Therefore the Vim help will by default disable the 'buflisted' option:

When this option is set, the buffer shows up in the buffer list. If it is reset it is not used for ":bnext", "ls", the Buffers menu, etc. This option is reset by Vim for buffers that are only used to remember a file name or marks. Vim sets it when starting to edit a buffer. But not when moving to a buffer with ":buffer".

This happens internally in the C code of Vim.

If you want to show unlisted buffers in the output of the :ls command, you can simply include the ! attribute, so :ls! will show also the help pages.

Alternatively, you can enable the 'buflisted' option in a filetype plugin for help files. To do so, add the following line to ~/.vim/after/ftplugin/help.vim (create non-existing directories, assuming Vim here):

setl buflisted

Make sure you have enabled :filetype plugin on to have Vim enable the newly created help filetype plugin.

2

Help buffers have the 'buflisted' option reset (see :help unlisted-buffer). When you set this option in the help buffer it will be listed by :ls.

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.