vimtricks.wiki Concise Vim tricks, one at a time.

How do I list all buffers including unlisted ones like help pages and terminal buffers?

Answer

:ls!

Explanation

:ls (or :buffers) shows Vim's buffer list, but it hides unlisted buffers — help files, directory listings (netrw), terminal buffers, and scratch buffers marked with u. Adding the ! bang includes all of these hidden entries, giving you a complete picture of every buffer loaded in the current session.

How it works

  • :ls — show the listed buffer list (normal files you are editing)
  • :ls! — show all buffers, including unlisted ones
  • Buffer flags in the output:
    • u — unlisted (present but hidden from :ls)
    • % — current buffer
    • # — alternate buffer
    • + — modified (unsaved changes)
    • h — hidden (loaded but not shown in any window)
    • - — unmodifiable buffer
    • = — read-only buffer
  • After seeing the list, switch to any buffer with :b {number} or :b {partial-name}

Example

:ls!

Sample output:

  1  u  "[No Name]"           line 0
  2  u  "[Command Line]"      line 0
  3  %a  "src/main.go"        line 42
  4  #h  "src/utils.go"       line 1
  5  u  "doc/help.txt"        line 0

Buffer 5 is a help file — it appears in :ls! but not in :ls.

Tips

  • :bdelete {n} removes a buffer from the list; :bwipeout {n} removes it entirely including undo history
  • To delete all unlisted buffers, combine with :ls! output: :%bdelete | e# to close all then reopen the last file
  • Plugin explorers (like vim-vinegar or netrw) create unlisted buffers — :ls! helps diagnose if they are accumulating

Next

How do I run a search and replace only within a visually selected region?