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

How do I collapse every tab page to a single window without closing tabs?

Answer

:tabdo only

Explanation

When you are deep in a refactor, each tab can accumulate helper splits, previews, and temporary views. :tabdo only is a fast cleanup pass that preserves every tab page but reduces each one to a single focused window. This is especially useful before a code walkthrough, pair session, or final review where visual noise slows navigation.

How it works

  • :tabdo runs an Ex command in every tab page
  • only closes all other windows in the current tab and keeps the active one
  • Combined, Vim walks tab-by-tab and applies only, giving you one window per tab
:tabdo only

Example

Before running the command:

Tab 1: main.go | tests split
Tab 2: README.md | terminal split | quickfix split
Tab 3: config.lua | help split

After running :tabdo only:

Tab 1: main.go
Tab 2: README.md
Tab 3: config.lua

Tips

  • Run :wall first if multiple windows contain unsaved buffers
  • Use this as a session reset before switching tasks
  • If you need to preserve a specific window in a tab, jump to it first, then run the command

Next

How do I make Vim transparently edit .gz files using built-in tooling?