I. Overview
First of all, VIM + cssag + ctags are really powerful. I feel very ashamed of it for me who have been playing in Linux for nearly two years. I have rarely used Vim before, and have never touched cssag and ctags. I also use gedit and find to view programs. Now, when I learned about Linux kernel, I found these three tools very useful. With them, I no longer have to search for the definition of a function or variable in the file list after finding, instead, you can easily find what you want. The most important thing is that you have increased your confidence in learning the Linux kernel. Here, we only record the three items in simple form (incomplete, which will be recorded later), so that we can easily query them later.
Ii. Notes
Run the make csout and make tags commands in the root directory of the Linux kernel source code. Several files, such as cscope. Out and tags, are generated under the root directory of the source code.
1.# Vim/path/filename
If the filename file exists, open it. If it does not exist, create it.
2. In command mode:
: Q exit, Q! Force exit (save not reported): W save,: WQ save and quit
/String + enter
Search string forward
? String + enter
Returns a string.
N
Find the next of the same string
N
Searches for the previous one of the same string in the opposite direction.
I
Enter edit mode
ESC buttons
Exit edit mode
V
Enter visual mode
In visual mode, right-click the top, bottom, left, and right-click the text:
Y indicates copying
P indicates pasting
X indicates cut
D Indicates deletion.
3. Use cscope
: CS add cscope. Out
Load the library file to prepare for later use of csflood for searching
: CS Help
View the usage of the cssag command. after entering the command, it is displayed as follows:
Add: Add a new database (usage: Add file | dir [pre-path] [flags])
Find: query a mode (usage: Find c | d | E | f | G | I | S | T name)
C: Find the function that calls this function.
D: Find the function called by this function.
E: Find the egrep mode.
F: Find this folder.
G: Find the definition.
I: Find a file # include this file
S: Find the C symbol.
T: Find the value assigned to it.
Help: display this information (usage: Help)
Kill: end a connection (usage: Kill #)
Reset: reset all connections (usage: reset)
Show: Display connections (usage: Show)
For example, if you want to find the function that calls the test function, enter:
: CS find C Test
4. Use catgs
In command mode:
CTRL +]: locate the label definition of the cursor
CTRL + T: return to the previous Tab
"Locate Tag: 1/3 or more" for other definitions:
: Tselect display list
Enter the corresponding number and press enter to search for it.
: Tag Definition
Jump to the definition Definition (which can be a function name or variable), even if it is in another file