Working with vim split windows

Sep 21, 2017 using tags vim

Vim split windows are very useful for folks who use vim as their primary IDE. You get the advantage of multiple windows in a single terminal without needing to use tmux or screen.

Split windows along with vim file explorer give you the advantage of a shared buffer among all open files, so copy/pasting and such becomes a lot simpler.

To split a window horizontally along the x axis:

:vs

To split a window vertically along the y axis:

:sp

To split a window horizontally and open file explorer:

:Vex

To split a window vertically and open file explorer:

:Sex

To set or adjust the height of a window:

:res 60  # resizes the height to 60 rows
:res +5  # increases the current height by 5 rows
:res -5  # decreases the current height by 5 rows

To set or adjust the width of a window:

:vertical res 60  # resizes the width to 60 columns
:vertical res +5  # increases the current width by 5 columns
:vertical res -5  # decreases the current width by 5 columns

To reset all window dimensions based on their splits:

Ctrl+w =