In vim, cscope is used to quickly locate the function definition and find the function prototype, which is very convenient.
On my fedora8 machine, cs.pdf has been installed by default.Program.
I am not very familiar with cssag. Many "advanced" functions will be available for further exploration. Here we will first write down the simple use of csflood in VIM so thatSource codeMedium:
1. quickly switch to the function definition.
2. function declaration.
3. query the usage of a function.
First, let Vim support csflood ~ /. Add the following to vimrc:
"Set cscopequickfix = s-, C-, D-, I-, T-, e -"
Second, in the sourceCodeDirectory to generate information about CSWs.
The libpcap code is used as an example.
# Cd/usr/code/Libpcap
# Cs1_rbq
# Import the generated cscope file to VIM
#: CS Add/usr/code/Libpcap/cscope. Out/usr/code/Libpcap/
Next we can perform the actual drill operation in vim.
1. move the cursor to a function. use Ctrl +] to jump to the function definition.
2. Find the Declaration and definition of a function:
: CS find G strcpy
3. If multiple function declarations and definitions are found, you can use the quickfix window to switch between them:
: CW
In addition, more functions can be used to find related help. The following describes some Cs find techniques that can be used.
----- The following is reprinted. author (Wu Yin)
-------- http://blog.csdn.net/wooin/archive/2007/10/31/1858917.aspx
cscope main function is achieved through the same sub-command "find"
"cscope find" Usage:
CS find c | d | E | f | G | I | S | T name
0 or S |
search for the c symbol (annotations can be skipped) |
1 or G |
search for this definition |
2 or D |
Find the function called by this function |
3 or C |
Find the function that calls this function |
4 or T |
search for this string |
6 or E |
find the current egrep mode |
7 or F |
search for this file |
8 or I |
Search for files containing this file |
it is really annoying to enter a long string of commands for each search. Some shortcut keys are recommended in the cssag help manual. Below are a group of them, I also use it. Add the following content ~ /. Vimrc and restart VIM:
NMAP S: CS find S = expand (" ") NMAP G: CS find G = expand (" ") NMAP C: CS find C = expand (" ") NMAP T: CS find t = expand (" ") NMAP E: CS find e = expand (" ") NMAP F: CS find F = expand (" ") NMAP I: CS find I ^ =expand (" ") $ NMAP D: CS find d = expand (" ") |
when the cursor stops on a word you want to search for, pressing G is to find the definition of the object. The same applies to other words.
one trick is to press this key combination. If you press , You need to press the next key immediately, otherwise, the screen will return to the nomal state as soon as it is flashed.
the G method is to press "Ctrl + Shift +-" first -", then press "G"