How do I list only modified or active buffers in Vim?
Answer
:ls +
Explanation
The :ls command (or :buffers) supports filter flags that narrow the buffer list to specific states. Instead of scrolling through dozens of buffers to find the ones you've changed, :ls + shows only modified buffers — making it easy to review unsaved work before quitting.
How it works
:ls— list all buffers:ls +— list only modified (unsaved) buffers:ls a— list only active (loaded and visible) buffers:ls h— list only hidden (loaded but not visible) buffers:ls u— list unlisted buffers (normally hidden from:ls):ls !— list all buffers including unlisted ones
Example
With 10 files open but only 2 modified:
:ls
1 h "README.md" line 1
2 %a + "src/main.go" line 45
3 h "src/handler.go" line 1
4 #h + "src/config.go" line 12
Running :ls + shows only:
2 %a + "src/main.go" line 45
4 #h + "src/config.go" line 12
The + flag in the listing confirms these buffers have unsaved changes.
Tips
- Use
:ls +before:qato check what needs saving - Combine with
:wallto save all modified buffers at once - The
%marker indicates the current buffer,#is the alternate buffer - In Neovim,
:ls tshows terminal buffers