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

How do I make Vim equalize split windows only horizontally?

Answer

:set eadirection=hor

Explanation

If you use many splits, automatic equalization can feel disruptive when Vim resizes both height and width after layout changes. The eadirection option controls which dimension is affected when equalization happens (for example with equalalways behavior or CTRL-W =). Setting it to hor limits equalization to horizontal sizing decisions, which keeps vertical structure more stable.

How it works

  • :set updates an option
  • eadirection means "equalalways direction"
  • hor tells Vim to equalize windows in the horizontal direction only

In practice, this is useful when you maintain stacked windows with carefully chosen heights and still want convenient width balancing as files open and close.

Example

Consider a three-way layout where top/bottom context matters:

+---------------------------+
| test output               |
+---------------------------+
| current source file       |
+---------------------------+
| logs                      |
+---------------------------+

When a new split appears, full equalization may flatten the layout too aggressively. With:

:set eadirection=hor

Vim focuses equalization behavior on horizontal distribution, reducing vertical churn.

Tips

  • Combine with :set equalalways if you want automatic balancing after split changes
  • Use :set eadirection=both to return to default behavior
  • This option is especially helpful on wide monitors with many side-by-side panes

Next

How do I store the current file path in a named Vim register?