Ctags This is a plugin for vim, which can be used to generate a retrieval file with some index information stored in it. For example, some classes are defined with methods, variables, etc.
When we execute ctags-r on a path, we automatically generate a ctags, and then we can use some shortcut keys to implement the jump, search and so on.
which
<c-]>-This command allows us to jump to the place where the cursor is located. Variable definition
I feel this ctags. When you generate an index, you should have some syntax recognition for the variable definition.
For example, for the following section of code
Private int a =56;
When we put the cursor on the second row of a, and then we do <C-]>, the cursor jumps to the first line
The above situation is that our a definition is the same file as the call, even if it is not in the same file, it can also jump.
For example
We have the following content in the Test_2.java
if (AAA = = +) {= +;}
In Test_3.java, there are the following:
private AAA = 67;
Then we execute Ctags-r *.java later. Then we put the cursor on AAA = = 40 AAA, and then we do <C-]>, the cursor will jump to Test_3.java's private AAA = 67;
It says that variables are defined only in one place, so what if we have more than one place where the variables are defined?
Let's take the example above, however, this time we add a test_4.java. The contents of it are also private AAA = 67; When we do the same, we will find that we have jumped to the Test_3.java. If we look at the tags file at this time, it is not difficult to understand why this is the case.
AAA Test_4.java int; $/;" External variable declarationsAAA Test_3.java int; $/;" external variable declarations
So, it should be a search from tags, when the first time to search for this variable, it will jump. In order to verify that the conjecture is correct, I specifically put the above two lines in the tags in the position of the exchange, and then re-> the above operation, the cursor jumps to Test_4.java. You can also see that it has the highest priority if the variable is defined in the current buffer file.
So if we don't want to jump directly to where it's defined by default, but want to choose for ourselves, then we can use
G<c-]>
The order.
Since Ctags supports indexes, the search results are a list, which not only reminds us of the usual way to use the results of VIM operations next prev. Specific as follows
Tselect-the last C-] search results. If we already have a search record, the stack will keep the record Tnext- The next tprev of the searchresults-the previous TFirst- Search results First Tlast-search results last article
Of course, these commands are also recommended for configuring shortcut keys.
In addition to the cursor being placed on the destination string to invoke <c-]>, we can also use the command line directly
: Tag {keyword}-equivalent to <C-]>
: tjump{keyword}-equivalent to G<c-]>
A more advantageous aspect of the command line is that it can also support regular expression searches. This time the command is
: Tag/{keyword}
: Tjump/{keyword}
Ctags Find Method Definition Place