Description of the key combination [c2i{] in the general command mode of vim

Geek.com vim must inform the website: https://time.geekbang.org/column/article/266754.

In the process of learning vim, I encountered the operation [c2i{] used in the general command line mode. I didn't understand what it meant at first. Through constant trial and error, I summarized some rules, which may not be right, at least it can be said in the past.

The test code is as follows.

#include <bits/stdc++.h>                                                                                                                                                                 
                        
int main()                 
{                       
    int a = 1;          
    int b = 2;          
    int c = 3;          
    for(int i=1;i<=4;i++)
    {                   
        if(a == 1)      
        {               
            printf("abc");
            if (b == 1)  
            {           
                printf("efg");
                if (c == 1)
                {       
                    printf("tao");
                }       
            }           
        }               
    }                   
    return 0;           
}

First of all, in some keys in vim, the d plus action can delete the text content, and the c plus action can modify the text content (that is, delete the original content, and then enter the insert mode). There are many key combinations for these keys, which are very practical. The key combination [c2i{] is one of them. For detailed instructions, please refer to the top website.
Next, let's look at the effects of the combination key [c2i{], the combination key [ci{], the combination key [c3i{], and the combination key [c4i{].
Move the cursor to line 18 in vim, as shown in the figure below.
Insert picture description here
The effect after pressing the key combination [ci{] is shown in the figure.
Insert picture description here
After deleting the content [printf("tao");] in the above figure, it immediately enters the insert mode. The combination key [ci{] is personally understood as change inside {, which means to change the content in {}. One thing to add is that compared to the combination key [ci{], there is also the combination key [ca{], which deletes the content in the braces together with the braces, and then enters the insert mode. The effect picture is as follows.
Insert picture description here

The effect diagram of pressing the key combination [c2i{] is as follows.
Insert picture description here
Now you can understand the difference between the combination key [c2i{] and the combination key [ci{]. The combination key [ci{] deletes the content in the innermost layer {} of the line where the current cursor is located and enters the insert mode , And the key combination [c2i{] deletes the content in the penultimate layer {} to which the line where the cursor is currently located, and enters the insert mode. In general, for the content [{ { {abc}}}] The combination key [ci{] deletes the content [abc] and enters the insert mode, and the combination key [c2i{] deletes the content [{abc}] and enters the insert mode. This can be extended to the combination key [c3i{] and the combination key [c4i{], and the effect diagrams are shown in the following two figures respectively. The cursor is initially on line 18 in the figure above.
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/ISs_Cream/article/details/107950555