How to use the vim multi-window function

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.