1.检查使用的vi或者vim是否支持cscope
$ vi --version| grep cscope
-cryptv -cscope -cursorshape -dialog -diff -digraphs -dnd -ebcdic -emacs_tags
$ vim --version | grep cscope
-conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff
Features included (+) or not (-)
+表示支持,-表示不支持。由上面的结果可以看出,vi不支持,vim支持;
可以看一下他们的路径,就知道他们不是不同的可执行程序;
$ which vi
/bin/vi
$which vim
/usr/bin/vim
2.如果vim没有支持cscope的话,可以自己下载vim的source进行编译:
2.1 download src from http://www.vim.org/download.php
2.2 extract gat file, cd src/
2.3 make distclean; rm auto/config.cache
2.4 edit Makefile file
430 # CSCOPE
431 # Uncomment this when you want to include the Cscope interface.
432 #CONF_OPT_CSCOPE = --enable-cscope -->
CONF_OPT_CSCOPE = --enable-cscope
or ./configure --enable-cscope
2.5 su root
ctags -R *
cscope -R
find . -name '*.java' -print > cscope.files
ctags -L cscope.files(ctags -e -L cscope.files )
cscope -ub -i cscope.files
直接使用就可以了,如果vim是6.0之后的,直接将该文件放在~/vim/plugin/下就可以了。
ctags: ctrl+T 返回; ctrl+] 到定义
cscope: ctrl+T 返回; ...
$ vi --version| grep cscope
-cryptv -cscope -cursorshape -dialog -diff -digraphs -dnd -ebcdic -emacs_tags
$ vim --version | grep cscope
-conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff
Features included (+) or not (-)
+表示支持,-表示不支持。由上面的结果可以看出,vi不支持,vim支持;
可以看一下他们的路径,就知道他们不是不同的可执行程序;
$ which vi
/bin/vi
$which vim
/usr/bin/vim
2.如果vim没有支持cscope的话,可以自己下载vim的source进行编译:
2.1 download src from http://www.vim.org/download.php
2.2 extract gat file, cd src/
2.3 make distclean; rm auto/config.cache
2.4 edit Makefile file
430 # CSCOPE
431 # Uncomment this when you want to include the Cscope interface.
432 #CONF_OPT_CSCOPE = --enable-cscope -->
CONF_OPT_CSCOPE = --enable-cscope
or ./configure --enable-cscope
2.5 su root
make; make INSTALL
ctags -R *
cscope -R
vim -t yoursymbol
find . -name '*.java' -print > cscope.files
ctags -L cscope.files(ctags -e -L cscope.files )
cscope -ub -i cscope.files
5. ctags和cscope在vi中的快捷键
5.1 cscope的快捷键定义可以自己定制,但是网上已经有了定义好的文件:http://cscope.sourceforge.net/cscope_maps.vim直接使用就可以了,如果vim是6.0之后的,直接将该文件放在~/vim/plugin/下就可以了。
ctags: ctrl+T 返回; ctrl+] 到定义
cscope: ctrl+T 返回; ...
6.你也可以单独使用cscope,使用方法是: cscope -d yoursymbol
refs:http://softsmith.blogspot.com/2009/01/vim-cscope-trace.html