Vim Learning to retreat-a wonderful combination of repeatable moves and repeatable changes

Source: Internet
Author: User

Date: 2014.06.29

Location: Base

----------------------------------------------------------------------------------

I. Task 1: Make changes repeatable

Adds a character before and after the specified character. For example, before and after the + operation of the connection string, a space is flowed ([]+[])

We know that the S command can remove the characters under the cursor into insert mode , and now we can summarize several ways to enter insert mode:

1. I command : Insert before current cursor

2. a command : Insert after current cursor

3. s command : Insert after the current cursor is deleted

4. Capital I command : Inserts the current cursor at the beginning of the

5. Capital A command : Inserts the current cursor at the end of the line

6. Capital S command : Delete the line where the current cursor is inserted

7. DD Command : Delete the current line only, will not enter the insert mode

So the small s command can delete the characters under the cursor into the insertion mode after the function, in order to complete the task we can first execute the small s command to delete the characters under the cursor , and then type: space + space, and then exit, so that the key collection:

[s space + space ESC] will be recorded to form a modification unit, then the order can be followed by the dot command. Now all we have to do is move the cursor to the next + sign and use it. command to perform this operation repeatedly.

----------------------------------------------------------------------------------

ii. Task 2: Make mobile repeatable

To find a specified character in our bank, we can use the F{char} command, such as f+, after which the cursor moves to the next + sign location. As a result, we can use f+ to jump to the next + number location of the line without completing a modification. However, a better approach is to use the ; number command to repeatedly find the characters that were found by the last F command . So there is no need to enter the f+ multiple times.

----------------------------------------------------------------------------------

three, the combination of the above two modes of movement and modification

Through the above, we know that the command can help us navigate to the next target character, and. The command can be repeated last modified so that we can work with it; it is possible to modify the + number to []+[].

Now for example, there is a line of code like this:

String Str= "You" + "is" + "my" + "world";
We would like to change the + number to []+[], the following steps:

1. First f+ the cursor to the first + sign

2. Small s command, remove the + sign character under the cursor into insert mode, and then type: []+[]

3.ESC Exit Modification

4. Repeat the last lookup with the number name, position the cursor

5. Use. Number of commands repeated last modification

6. Repeat steps 4 and 5 until the modification is complete.


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.