Vim multi-window editing

Source: Internet
Author: User
Vim multi-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. Multi-window editing is dynamic when you start multi-window Editing. you can open multiple windows when you start editing, or add new windows when you work... vim multi-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. As shown in the following figure: If the image 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 is not visible for the moment, but can still be used. -O is followed by a number n, which is a pre-allocated window. Open: $ vim-o5 file1 file2. five identical windows will be allocated, there are three idle vim multi-window edits: 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 and edit the file in any window (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, use the parameters of the new file to pass to: split Command: split otherfile option to split the window: [n] split (vsplit) [++ opt] [+ cmd] [file]: n indicates the number of lines that vim specifies in the new window, the size of the new window is equal to the number of rows. 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 horizontally split in read-only mode to open a new window: sfind [++ opt] [+ cmd] [file] works in a similar way as split, but filename is searched in path, if the vim file is not found, it is not displayed in the window and moved between gvim or vim. moving in the window is actually very simple, because gvim By default, you can click the mouse to change the editing window. in vim, you can open the mouse option ,: set mouse = a activates the mouse for commands, inputs, and navigation. we know that vim can work without the mouse, so we can use the complete set of navigation commands provided by vim, 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 move Ctrl + w + t cyclically in all windows: move to the top left corner of the window Ctrl + w + B: move to the bottom right corner of the window Ctrl + w + p: in vim, there are two ways to move the window to the previous one. 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 and adjust the size to fill in the moving position of the window. 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 moves Ctrl + w + x along with the window: switches 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 CtrlCtrl + 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 end of the screen and occupy all Height ^ WL: move the window to the right end of the screen and occupy all Height ^ WT: move the window to the New existing page of the screen 3. adjust the window size to change the size of the current window, but 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, the resize + n explicitly specifies the increase of the size Ctrl + W + <: reduce the width of the current window Ctrl + W +>: increase the width of the current window by Ctrl + W + |: increase the width of the current window to the maximum. you can also run the "ex" command: vertical resize n explicitly specifies the change width. in addition to multi-window editing, vim also 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: there are four ways to close the window when you move to the previous page to close and exit the window: Exit (quit), close (close), hide (hide) to close other windows ^ indicates the Ctrl key ^ Wq, leaves the current window ^ Wc, closes the current window ^ Wo, and closes all Windows other than the current window

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.