:sp<- shorthand for split
:vsp<- shorthand for vsplit
When called from the command line, multiple files can be provided in the argument and vim will create one split for each file. When called from ex mode, only one file can be opened per invocation of the command.
Changing the size of a split or vsplit
You may sometimes want to change the size of a split or vsplit.
To change the size of the currently active split, use
:resize <new size>.
:resize 30 for example would make the split 30 lines tall.
To change the size of the currently active vsplit, use
:vertical resize <new size>.
:vertical resize 80 for example would make the vsplit 80 characters wide.
- Ctrl + w and + increase the size of the splited window
- Ctrl + w and - decrease the size of the splited window
- Ctrl + w and = set an equal size to the splited windows
Close all splits but the current one
Managing Open Split Windows (Keyboard Shortcuts)
After you have opened a split window in vim (as demonstrated by many examples under this tag) then you will likely want to control windows quickly. Here is how to control split windows using keyboard shortcuts.
Move to split Above/Below:
- Ctrl + w and k
- Ctrl + w and j
Move to split Left/Right:
- Ctrl + w and h
- Ctrl + w and l
Move to split Above/Below (wrap):
- Ctrl + w and w
Create new empty window:
- Ctrl + w and n -or- :new
Create new split horizontal/vertical:
- Ctrl+W, S (upper case)
- Ctrl+W, v (lower case)
Make the currently active split the one on screen:
- Ctrl + w and o -or- :on
Move between splits
To move to split on left, use
To move to split below, use
To move to split on right, use
To move to split above, use
Opening a new split window
You can open a new split within Vim with the following commands, in normal mode:
split will open the file in a new split at the top or left of your screen (or current split.)
:vs are convenient shortcuts.
new will open an empty split
Opening multiple files in splits from the command line
You may optionally specify the number of splits to open. The following example opens two horizontal splits and loads
file3.txt in a buffer:
Sane split opening
It's a better experience to open split below and on right
set it using