How do I control exactly where a new split window appears in Vim?
Answer
:topleft split {file}
Explanation
By default, Vim places horizontal splits below and vertical splits to the right (controlled by splitbelow and splitright). But sometimes you need a split in a specific position regardless of your settings — for example, putting a help window at the very top of the screen or a terminal at the very bottom. The position modifier commands :topleft, :botright, :leftabove, and :rightbelow give you precise control over split placement.
How it works
:topleft split {file}— opens a horizontal split at the very top of the entire Vim layout:botright split {file}— opens a horizontal split at the very bottom of the entire Vim layout:leftabove split {file}— opens the split above or to the left of the current window:rightbelow split {file}— opens the split below or to the right of the current window
The key difference: :topleft and :botright position relative to the entire screen, while :leftabove and :rightbelow position relative to the current window.
Example
Open a terminal at the very bottom of the screen, regardless of your splitbelow setting:
:botright terminal
Open a reference file at the very top while editing:
:topleft 15split notes.md
This creates a 15-line window pinned to the top of the screen.
Tips
- These modifiers work with
:vsplittoo::topleft vsplitcreates a full-height split on the far left - Combine with size:
:botright 10splitfor a fixed-height split at the bottom - These are especially useful in plugin development and custom layouts where consistent window placement matters