minimal cscope example
Ingo mentioned this, here is an example.
Go to the base directory of your project and run:
cscope -Rb
This generates a cscope.out file containing the parsed information. Generation is fast enough, even for large projects such as the Linux kernel.
Open vim and run:
:cs add cscope.out :cs find c my_func
c is mnemonic for callers . Other possible cscope queries are also possible, the mnemonics are listed below:
help cscope
This adds the caller list to the quickfix list, which you can open with:
:copen
Scroll to the line you are interested in and press enter to go there.
To find the subscribers of the function name under the cursor, add to your .vimrc :
function! Csc() cscope find c <cword> copen endfunction command! Csc call Csc()
and enter :Csc<enter> when the cursor is over the function.
TODO:
- do this for the current function under the cursor with a single command. Related: Vim: show function name in status bar
- automatically adds the nearest database (parent directories) when entering a file: how to automatically load cscope.out in vim
- interactively open a call graph, such as Eclipse. Related: Generate call tree from cscope database
A word of advice: I love vim, but for me it is too difficult to configure this. If the project is enough for you, try getting the project to work on some kind of "IDE". This may be due to some overhead if the project does not track IDE configuration files (which automatically change drops that pollute the repo ...), but it's worth it. For C / C ++, my favorite so far has been KDevelop 4.
Ciro Santilli ๅ
ๅญ ้ฒ ๅฎช ๅ
ญๅ ไบไปถ ๆณ่ฝฎๅ
source share