Generally, editing software provides the "cut window or freeze window" function, so that one or more files are displayed in multiple windows. Vim also has this function.
The following is a summary of the multi-window operations in Vim.
I. Opening and closing windows
1.1 open a new separation window
: Sp [filename] // open a new file in a new window
: Sp // the same file is opened by default.
To open a new window and edit an empty buffer, you can use:
: New
1.2 Close the window
: Close
: Close can close the current window.
In fact, any command like ": q" and "ZZ" to exit file editing will close the window, but ": close" will prevent you from closing the last Vim, to avoid accidental shutdown of the entire Vim.
If you want to close all other windows except the current window, use:
: Only
II. Window size settings
2.1 New window height initialization:
: Nsp
N indicates the number of rows in the new window.
For example, a new window with 3 rows in height is opened: 3sp.
2.2 The window height setting is enabled:
2.2.1 Method 1: drag and drop the mouse to zoom in the window;
2.2.2 Method 2: CTRL-W
Increase current window height: CTRL-W +
Decrease current window height: CTRL-W-
Both commands can receive a note to increase or decrease the specified number of rows at a time ." 4 vtrl + w + "will increase the height of the current window by four rows.
Specify window height as a fixed height: {height} CTRL-W _.
Make the window reach its maximum possible height: directly use CTRL-W without specifying the command count.
3. Move the cursor between multiple windows
Button description
CTRL-W + h to left window
CTRL-W + j to the following window
CTRL-W + k to the above window
CTRL-W + l to right window
CTRL-W + t to top window
CTRL-W + B to bottom window