Too simple to say, just find a manual can find, here to say some tips, but also recently used to force out of the study, hehe, but quite convenient.
1. Global replacement
(1) v + G + $ Select all, then enter: s/original string/target string/
(2):%s/original string/target string/
2. Clear the blank characters at the end of all lines in the page:
:%s//s/+$//
3. Clear All Blanks
:%s//(/s*/n/)/+//r/
4. Remove All//comments
:%s!/s*//.*!!
5. Remove All/*/comments
:%s!/s*//*/_./{-}/*//s*!!
6. Do some internal data repeat replacement
Sometimes we need to organize some batch of data to execute the command line, for example, we need to use the previous data to generate the following data, such as the data:
/var/database/aaa.txt
/var/database/bbb.txt
/var/database/ccc.txt
I would like to become a command, such as to become a copy of the commands, copied to the previous directory, then you can execute:
:%s//(. *base///)/(. */.txt/)/CP/1/2/.///2/
has become:
Cp/var/database/aaa.txt./aaa.txt
Cp/var/database/bbb.txt./bbb.txt
Cp/var/database/ccc.txt./ccc.txt
The key here is the use of the Sub mode: () in the middle,/1 represents the first found child mode,/2 for the second, and so on, vim inside () must be escaped, unlike other languages
7. Add comments (one operation applied on multiple lines)
such as the need to add # or is//this annotation:
Ctrl + V navigates to the start line, then selects the desired row, then execute the I command, then enter # or//, and press ESC two times to apply the annotation operation to all selected rows, remembering that the V directive should not be used, and that the CTRL + V should be used (to clear the comment to refer to the above method) (V is selected by row) , Ctrl + V is selected by column)
8. The Hyphenation
V to select the rows to be neat, enter = warping
9. Open multiple Windows
Use in vim: the SP file name opens the row window (horizontal), uses: The VSP file name opens the column window (vertical), uses: Q Closes the current window, uses: QA Closes all windows, uses Ctrl + W to switch in each window.
Maximized window: Ctrl + W activates a window, then SHITF +-maximizes
Change the window to the specified line height: Ctrl + w activates the window, 10 (the number of line sizes needed to be changed), Shift +-, performing changes
Increased number of Line heights: Ctrl + w activation window, 10 (need to increase the row size number), SHIFT + +, perform changes
10. String/Variable Hints
In the input state, press CTRL + P to display all the strings defined on this page, if you enter a string portion of the content, and then press CTRL + P to display all of the contents of the beginning of your input string. Press Ctrl + x in the input state to view all other methods that are valid
Reference URL:
http://www-128.ibm.com/developerworks/cn/linux/l-tip-vim1/
Http://man.chinaunix.net/newsoft/vi/doc/help.html