empty file, use this: >
:new
You can repeat the ":split" and ":new" commands to create as many windows as
you like.
==============================================================================
*08.3* Window size
The ":split" command can take a number argument. If specified, this will be
the height of the new window. For example, the following opens a new window
three lines high and starts editing the file alpha.c: >
:3split alpha.c
For existing windows you can change the size in several ways. When you have a
working mouse, it is easy: Move the mouse pointer to the status line that
separates two windows, and drag it up or down.
To increase the size of a window: >
CTRL-W +
To decrease it: >
CTRL-W -
Both of these commands take a count and increase or decrease the window size
by that many lines. Thus "4 CTRL-W +" make the window four lines higher.
To set the window height to a specified number of lines: >
{height}CTRL-W _
That's: a number {height}, CTRL-W and then an underscore (the - key with Shift
on English-US keyboards).
To make a window as high as it can be, use the CTRL-W _ command without a
count.
USING THE MOUSE
In Vim you can do many things very quickly from the keyboard. Unfortunately,
the window resizing commands require quite a bit of typing. In this case,
using the mouse is faster. Position the mouse pointer on a status line. Now
press the left mouse button and drag. The status line will move, thus making
the window on one side higher and the other smaller.
OPTIONS
The 'winheight' option can be set to a minimal desired height of a window and
'winminheight' to a hard minimum height.
Likewise, there is 'winwidth' for the minimal desired width and
'winminwidth' for the hard minimum width.
The 'equalalways' option, when set, makes Vim equalize the windows sizes
when a window is closed or opened.
==============================================================================
*08.4* Vertical splits
The ":split" command creates the new window above the current one. To make
the window appear at the left side, use: >
:vsplit
or: >
:vsplit two.c
The result looks something like this:
>
+--------------------------------------+
|/* file two.c */ |/* file one.c */ |
|~ |~ |
|~ |~ |
|~ |~ |
|two.c===============one.c=============|
| |
+--------------------------------------+
<
Actually, the | lines in the middle will be in reverse video. This is called
the vertical separator. It separates the two windows left and right of it.
There is also the ":vnew" command, to open a vertically split window on a new,
empty file. Another way to do this: >
:vertical new
The ":vertical" command can be inserted before another command that splits a
window. This will cause that command to split the window vertically instead
of horizontally. (If the command doesn't split a window, it works
unmodified.)
MOVING BETWEEN WINDOWS
Since you can split windows horizontally and vertically as much as you like,
you can create almost any layout of windows. Then you can use these commands
to move between them:
CTRL-W h move to the window on the left
CTRL-W j move to the window below
CTRL-W k move to the window above
CTRL-W l move to the window on the right
CTRL-W t move to the TOP window
CTRL-W b move to the BOTTOM window
You will notice the same letters as used for moving the cursor. And the
cursor keys can also be used, if you like.
More commands to move to other windows: |Q_wi|.
==============================================================================
*08.5* Moving windows
You have split a few windows, but now they are in the wrong place. Then you
need a command to move the window somewhere else. For example, you have three
windows like this:
>
+----------------------------------+
|/* file two.c */ |
|~ |
|~ |
|two.c=============================|
|/* file three.c */ |
|~ |
|~ |