Today, in December September 13, 2014, the code under Vim is automatically indented and replaced with the string of the visible area. We have been using vim, a powerful editor. Only the users who use it know its power, now we can display these two powerful functions. These two functions are handy even if you do not indent the code, or you want to modify the string of the specified region, for more information, see implementation:
1. Automatic Code indentation:
I: Open the vim editor and open a code. The code is not indented at this time, for example:
Now the point is, execute the command:
I want to implement all indentation, so place the optical punctuation at the beginning of the code, and the CTR-V enters the visualization area;
G is selected to the last line of all code. Of course, you can also select the specified line indent, for example, 20 rows, that is, 20 GB;
$ Position the cursor in the last character of the last line;
= Realize Automatic Code indent.
2. String replacement in the visible area:
For example, to replace Line 10-20 with helloworld, first place the cursor at the beginning of Line 10 and execute the following command:
CTR-V enters the visualization area;
20 GB to 20 rows;
$ Move the cursor to the end of the 20 rows, so that 10-20 rows are selected;
C. Enter the editing status and write the string helloworld;
Press ESC to replace.
Vim implements code indent and string replacement in the visible area