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

How do I control whether a new split opens above, below, left, or right of the current window?

Answer

:leftabove / :rightbelow / :topleft / :botright

Explanation

Vim provides split modifier commands that override the default placement of new windows. Prefix any split command with :leftabove, :rightbelow, :topleft, or :botright to control exactly where the new window appears.

The modifiers

Modifier Horizontal split Vertical split
:leftabove / :aboveleft Opens above Opens to the left
:rightbelow / :belowright Opens below Opens to the right
:topleft Opens at the very top Opens at the far left
:botright Opens at the very bottom Opens at the far right

Examples

Open a help window at the very top of the screen:

:topleft help quickref

Open a terminal at the bottom:

:botright terminal

Split a file to the left of the current window:

:leftabove vsplit other.py

Open a new buffer below:

:rightbelow new

Default behavior

Without modifiers, Vim uses these options:

  • :set splitbelow — horizontal splits open below (default: above)
  • :set splitright — vertical splits open to the right (default: left)

Most users add both to their vimrc for a more natural layout.

Tips

  • The modifiers are one-shot — they only affect the immediately following command
  • :vert topleft split opens a full-height split at the far left edge (great for file browsers)
  • These modifiers work with :terminal, :help, :split, :vsplit, :new, :vnew, and more
  • Abbreviations: :abo = :aboveleft, :bel = :belowright, :to = :topleft, :bo = :botright

Next

How do I run a search and replace only within a visually selected region?