Vim implements code indent and string replacement in the visible area

Source: Internet
Author: User

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

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.