Vim vimdiff operations

Source: Internet
Author: User

Vim vimdiff Shell: Ctrl + R (reverse lookup history command) vim: vim added the multi-tag switching function from vim7, which is equivalent to multiple windows. although the previous version also has multiple file editing functions, it is not as convenient as it is. Usage: tabnew [++ opt option] [+ cmd] Create a new tab for the specified file: tabc close the current tab: tabo close all other tabs: tabs view all opened tabs: the previous one: tabn and the next standard mode: gt, gT can be directly switched between tabs. There are a lot of other commands, such as the help table. Multi-Window Creation and focus switching: it is easy to open multiple windows in Vim. There are also more than one methods. Run the command: new by default, a new window is opened horizontally. Another command is split (sp ). However, the default horizontal split is a bit uncomfortable, because the screen is a wide screen, and the code is almost not written so long, but the actual lack of vertical space, so this time we need to use vertical split, the command is: vsplit (vs), which is easy to understand. After opening so many windows, I don't know how to switch between them. Switching is also very easy. Press ctrl + w and then use j/k to locate the window. Pay attention to the changes of the window cursor. However, I personally think this is quite troublesome. Each time you switch the window, you must press the combination key first. Fortunately, there is another way, that is, press ctrl + w twice consecutively, and vim will automatically jump to the next window. In addition, the command to change the window width is: Crtl + w> extend the current window to the right, and change> to <to expand a row to the left. You can also use numbers to represent the number of expanded rows, 5 Ctrl + w>, and 5 rows to the right. Changing the window height is similar, but the command is Ctrl + w + to increase the height and-decrease the height. Vimdiff: Start vimdiff Method 1: # vimdiff FILE_LEFT FILE_RIGHT Method 2: # vim-d FILE_LEFT FILE_RIGHT method 3: # vim FILE_LEFT open vim and input: vertical diffsplit FILE_RIGHT window Layout Switch Ctrl-w K (Move the current window to the top) Ctrl-w H (Move the current window to the far left) ctrl-w J (Move the current window to the bottom) Ctrl-w L (Move the current window to the far right) Adjust the size of the window Ctrl-w = (adjusted to an equal value) ctrl-w-(zoom in height) Ctrl-w + (Increase height) Ctrl-w>/<(adjust width to the right/left) switch the focus of the window, switch the current window CTRL-w h to jump to the Left window CTRL-w j to jump to the following window CTRL-w k to jump to the above window CTRL-w l to jump to the right window CTRL-w t jump The top window CTRL-w B Jump to the bottom window CTRL-w jump to another window, the same as CTRL-w move the cursor, the split window moves synchronously. You can run the: set noscrollbind command to cancel synchronization.] c jumps to a different place. [c jumps to a different place. Context collapse is performed by default, vimdiff folds and hides the same text except the top 6 lines in the file. You can use: set diffopt = context: 3 to modify the number of displayed context lines. Zo Folding Open. It is said that "z" is used instead, because "z" is more like an origami) other fold zf create fold (use a number to show the number of rows from the current row to the bottom, for example, 3 J creates a fold that includes four rows) zo Open fold (l can also open fold) zc close current fold zm close all fold zr open all fold zE delete all fold zd delete current fold za if current open close, if this function is disabled, zk is opened from zj to the start of the next fold to the end of the previous fold and dp (diff put) is merged) copy the content at the cursor position of the current window to do (diff obtain) in another window, copy the content at the cursor position of the other window to diffupdate in the current window, and then compare the two files, if you manually modify the file, the file operation will not be automatically synchronized. yy: copy the current row. nyy: copy the n rows starting from the current row. dd: Delete the current row. ndd: Delete the n rows starting from the current row. p: paste u: Undo CTRL -r is repeated (that is, cancellation is canceled)) Wa save all wqa save all and exit qa quit qa! Force exit all. Do not save the file. Modify vim-o file1 file2. Open two windows horizontally and display the content of two files. vim-O file1 file2. Open the bookmarks vertically: ma adds bookmarks a' a to jump to the bookmarks row a move: [n]> Move the current row to the right of a unit (tab) [N] <Move the current row to the left of a unit search function: /word search for word backward, n continue to search downward? Word search forward word * find the word at the cursor, find down # Find the word at the cursor, and look up the alignment function: configuration file ~ /. Vimrc: set autoindent [n] = set autoindent jump function: "[{" jump to the start of the containing statement "]}" jump to the end of the containing statement "[[" Jump to the start of the function containing the statement "] [" Jump to the function containing the statement alias function at the end: AB abbr stringeg: AB mylog pr_info ("LC112 [% s] called ===\ n", _ func _); When mylog is input, it is automatically replaced with pr_info ("LC112 [% s] called ===\ n", _ func __); similar to the macro function of C language, you can also create your own in each directory. vimrc file to meet different needs. For example, you can create a program in the directory where the C ++ source program is located. vimrc file, which can be created in the directory of the document to be compiled. vimrc file. However, it should be noted that only when the. exrc file in the user's main directory contains the "set exrc" command, the. vimrc file in other directories can play a role.

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.