: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.
vim -o file1.txt file2.txt
vim -O file1.txt file2.txt
You may optionally specify the number of splits to open. The following example opens two horizontal splits and loads
file3.txt in a buffer:
vim -o2 file1.txt file2.txt file3.txt
You can open a new split within Vim with the following commands, in normal mode:
:split <file name> :new
:vsplit <file name> :vnew
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
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.
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:
Move to split Left/Right:
Move to split Above/Below (wrap):
Create new empty window:
Create new split horizontal/vertical:
Make the currently active split the one on screen:
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
It's a better experience to open split below and on right
set it using
set splitbelow set splitright