Monday, August 24, 2009

vim + ctags + cscope

http://adrianhuang.blogspot.com/2007/09/trace-code-gvimctagscscope.html
http://blog.linux.org.tw/~jserv/archives/001608.html
http://cscope.sourceforge.net/cscope_vim_tutorial.html
http://cscope.sourceforge.net/cscope_maps.vim

Install ctags and cscope first.
Put cscope_maps.vim into .vim/plugin/.
In the dir you want to trace,
$ ctags -R && cscope -R
It will generate ctags and cscope.out, then you can do following command in vi.

ctags:
Ctrl+] : find the tag definition
Ctrl+t : go back

cscope:

Ctrl+\, s :

find all references to the token under cursor

Ctrl+\, c :

find all calls to the function name under cursor

[Note] To trace java code:
$ find . -name '*.java' > cscope.files
$ cscope -b

No comments:

Related Posts Plugin for WordPress, Blogger...