level 9
1.
如果遇到duplicate database
信息如下
line 42:
E568: duplicate cscope database not added
Press ENTER or type command to continue
那么就是vim的全局配置中也有cscope add cscope.out
和cscope_maps.vim或者用户的vim配置文件中的cscope add cscope.out冲突了
2015年01月22日 06点01分
1
level 9
2.
如果cscope_maps.vim中定义的cscope的快捷键失效,记得在vim的配置文件中加上
set nocompatible
这样就不会去兼容老的vi,在兼容老vi的情况下,会使键的mapping无效
The set nocompatible setting makes vim behave in a more useful way (the default) than the vi-compatible manner. Remove the “no” to keep the old vi behavior. The set backspace=2 setting allows backspacing over line breaks, autoindents, and the start of insert. The syntax on parameter enables vim's syntax highlighting. Finally, the if statement with the set background=dark setting corrects vim's guess about the background color of some terminal emulators. This gives the highlighting a better color scheme for use on the black background of these programs.
2015年01月22日 06点01分
2
level 9
然后去你的源码目录, 如果你的源码是多层的目录, 就去最上层的目录, 在该目录下运行命令: ctags -R
我现在以 vim71 的源码目录做演示
$ cd /home/wooin/vim71$ ctags -R
此时在/home/wooin/vim71目录下会生成一个 tags 文件, 现在用vim打开 /home/wooin/vim71/src/main.c
$ vim /home/wooin/vim71/src/main.c
再在vim中运行命令:
:set tags=/home/wooin/vim71/tags
该命令将tags文件加入到vim中来, 你也可以将这句话放到~/.vimrc中去, 如果你经常在这个工程编程的话.
下面要开始真刀实枪的开干了, 如下图, 将光标放在setmouse()函数上
此时按下<C-]>, 光标会自动跳到setmouse()函数的定义处, 见下图:
2015年01月22日 07点01分
3
level 9
先在~/vimrc中增加一句:
:set cscopequickfix=s-,c-,d-,i-,t-,e-
这个是设定是否使用 quickfix 窗口来显示 cscope 结果, 用法在后面会说到。
进入vim后第一件事是要把刚才生成的cscope文件导入到vim中来, 用下面的命令:
:cs add /home/wooin/vim71/cscope.out /home/wooin/vim71
上面这条命令很重要, 必须写全, 不能只写前半句:
:cs add /home/wooin/vim71/cscope.out
因为源码是多级目录的, 如果这样写, cscope是无法在子目录中的源码中工作的, 当然, 如果你的源码都在同一级目录中就无所谓了. 如果你要经常用cscope的话, 可以把上面那句加到~/.vimrc中去.
2015年01月22日 07点01分
4
level 9
下面我们来操练一下, 查找函数vim_strsave()的定义, 用命令:
:cs find g vim_strsave
2015年01月22日 07点01分
5