1、安装Cscope
sudo apt-get install cscope
2、在/etc/vim/vimrc文件中加入以下内容
"enable the cscope in vim if filereadable("cscope.out") cs add cscope.out endif
3、进入想要看的文件夹目录: 例/home/linx/kernel/linux-3.6.3/drivers/char
cd kernel/linux-3.6.3/drivers/char/
4、建立索引
cscope -Rbq #-R Recurse directories for files. #-b Build the cross-reference only. #-q Build an inverted index for quick symbol searching.
5、打开想要查看的文件: 例 misc.c
vim misc.c
6、使用底行添加路径
:cs add ~/kernel/linux-3.6.3/drivers/char/cscope.out ~/kernel/linux-3.6.3/drivers/char
7、索引: 例 static LIST_HEAD(misc_list);
:cs find s LIST_HEAD
8、cscope强化:在/etc/vim/vimrc中加入如下内容
"use the Ctrl+Shift+\ and [sgctefid] shorted for the code cs find [sgctefid] nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR> nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
9、now, enjoy it.