Vim starts multi-window editing and vim starts window editing.

Source: Internet
Author: User

Vim starts multi-window editing and vim starts window editing.
Vim provides the multi-window editing function to simplify compound editing tasks. The multi-window mode of vim does not mean that multiple vim instances are started on the terminal.
Enable multi-window editing. The multi-window editing is dynamic. You can open multiple windows when you start editing, add new windows at any time during work, or delete a window. $ Vim-o file1 file2 opens an editing session, which is displayed as a horizontally split window in two halves. A file occupies one window. $ Vim-O file1 file2 is the same as above, but it is a Vertical Split Window
As shown in the following figure:

If the split screen is not enough to accommodate all the windows, the first file occupies most of the windows, and the remaining windows are loaded into the buffer zone, which cannot be seen yet, but can still be used.

-O is followed by a number n, which is the form of a pre-allocated window open: $ vim-o5 file1 file2 will be allocated five identical windows, three of which are idle
Vim multi-window Editing: split creates a new window and splits the current window into two halves. they display the same buffer content (the same file ). In this way, you can browse the same file in two windows.
: Vsplit creates a new Vertical Split Window, which also displays the same file content as the current window. The effect is as follows:
When you edit the same file in multiple windows (such as deleting a row), all windows with the same file will reflect the effect at the same time, because they share the same file buffer.
If you want to edit or browse another file and do not want to lose the editing position in the current file, you can use the parameters of the new file to pass to: split command: split otherfile
Split Window Options: [n] split (vsplit) [++ opt] [+ cmd] [file]
Command: n indicates the number of lines displayed in the new window for vim, and the size of the new window is equal to the number of lines, the new window is located at the top of the screen. opt sends the vim option information to the new window session (note that two plus signs must be added before it) cmd refers to the command to be executed in the new window (note that a plus sign must be added before it) file specifies the file to be edited in the new window
: Sview filename is split horizontally in read-only mode to open a new window: sfind [++ opt] [+ cmd] [file] works in a similar way as split, however, filename is found in path. If vim does not find the file, it is not displayed.
Moving between windows in gvim or vim is actually very simple in the window, because gvim supports mouse clicking to change the window by default, while in vim, you can open the mouse option ,: set mouse = a indicates that the mouse is activated for commands, input, and navigation.
We know that vim can work without the mouse, so we can use the complete set of navigation commands provided by vim to quickly and accurately move the editing window in sessions.
Press Ctrl + W and add h, j, k, and l to move the window Ctrl + w + h to the left, bottom, top, and right respectively: move the window to the left Ctrl + w + j: Move the window down Ctrl + w + j: Move the window up Ctrl + w + l: Move the window to the right
Ctrl + w: This command will cyclically move Ctrl + w + t in all windows: Move Ctrl + w + B to the upper left corner of the window: move to the bottom-Right window Ctrl + w + p: Move to the previous access window
There are two ways to move a window in vim: one is to simply switch the window on the screen and the size remains unchanged; the other is to change the actual layout of the window, it also adjusts the size to fill the position where it moves.
1. Move the window itself (rotation or switching) Ctrl + w + r: Switch the window to the right or below, while Ctrl + w + R is in the opposite direction.
The cursor will move with the window
Ctrl + w + x: Switch the position of the window in the same column or in the same row. By default, vim switches the position of the current window and its next window. If there is no window below, it tries to swap the position with the previous window. You can also add the number before this command to swap the location with the specified window.
2. Move the window and change its layout. Note: The third letter below is uppercase. Press Ctrl + w and then press shif + the corresponding letter. Use ^ instead of Ctrl + w + K to move the current window to the top of the screen and occupy all the width ^ WJ: Move the window to the bottom of the screen and occupy all the width ^ WH: move the window to the left of the screen and occupy all height ^ WL: Move the window to the right of the screen and occupy all height
^ WT: Move the window to the new existing page
3. Adjust the window size to change the current window size, and of course it will also affect other windows. In gvim and vim, you can click the white bar on the top of the window and adjust the size of the window.
You can also directly use the command to adjust the size. The command also starts with Ctrl + W: Ctrl + W + =: adjust all windows to the same size (average partition) Ctrl + W + -: to reduce the height of the current window by one line, you can also specify the size of the decrease by pressing: resize-4 Ctrl + W ++: to add a row to the height of the current window. Similarly, in the ex command, resize + n explicitly specifies the size to be increased.
Ctrl + W + <: decrease the width of the current window Ctrl + W +>: Increase the width of the current window
Ctrl + W + |: Adjust the width of the current window to the maximum. Alternatively, you can use the ex command: vertical resize n to explicitly change the width.
In addition to multi-window editing, vim allows you to create multiple tabs. Each page has its own behavior, similar to the paging browsing function of firefox or chrome.
We can use paging in vim or gvim, but it is better to use it in gvim. The final command: tabnew filename opens a new page and edits the new file (optional ). If no file is specified, only the new page is opened and the oversea buffer is attached. : Tabclose close: tabonly closes all other pages. If a file has been modified in other pages, the page is not removed unless the autowrite option is set. In this case, all modified files are written to the disk before the paging is disabled.
You can hover the cursor over another page or press Ctrl + PageDown to move to the next page. Ctrl + PageUp: Move to the previous page.
There are four ways to close a window: exit (quit), close (close), hide (hide), and close other windows.
^ Indicates the Ctrl key ^ Wq, leaving the current window ^ Wc, closing the current window ^ Wo, closing all windows other than the current 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.