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

How do I keep a split at a fixed width when opening and closing other windows?

Answer

:setlocal winfixwidth

Explanation

When you use a sidebar-style split for file trees, docs, or logs, automatic window equalization can constantly resize it. That visual jitter makes navigation slower and wastes attention. :setlocal winfixwidth keeps the current window's width stable while other windows change around it.

This is most useful in multi-split layouts where one narrow pane should stay predictable and your main editing area should absorb size changes.

How it works

  • :setlocal applies the setting only to the current window
  • 'winfixwidth' tells Vim/Neovim not to change this window's width during automatic layout adjustments
  • Other windows can still be resized normally

Example

Left split: docs/help pane (30 columns)
Right split: code editor

Enable :setlocal winfixwidth in the left pane. Now opening quickfix, help, or temporary splits tends to resize the main editing pane first, while the sidebar width remains stable.

Tips

  • Pair with :vertical resize 30 to set the initial width precisely
  • Disable later with :setlocal nowinfixwidth
  • For horizontal stability, use 'winfixheight' on short utility panes

Next

How do I launch a GDB session in Vim with the built-in termdebug plugin?