安装
yum install cscope -y

index
cscope -Rbkq

vi配置

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" cscope setting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("cscope")
  set csprg=/usr/bin/cscope
  set csto=1
  set cst
  set nocsverb
  " add any database in current directory
  if filereadable("cscope.out")
      cs add cscope.out
  endif
  set csverb
endif

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>

用法

vi中添加cscope数据库

. vi命令模式添加
  :cs add cscope.out
. .vimrc中自动添加
  见上面vimrc配置

vi中重新加载cscope数据库

// 如果需要重建index
:!cscope -Rbq
:cs show
:cs reset cscope.out

符号查找:

. vi命令模式:
  :cs find s xxx
. 快捷键:
  配置见上面vimrc配置
  光标置于符号 ctrl+\ s

其它快捷键:

ctrl+]:跳转到函数定义
ctrl+t:返回上一个查找的地方

其它
. c++支持

#!/bin/sh
find . -name ”*.h” -o -name ”*.c” -o -name ”*.cc” > cscope.files
cscope -bkq -i cscope.files
ctags -R

https://www.cnblogs.com/zendu...


黑暗森林
12 声望3 粉丝

弱小和无知不是生存的障碍,傲慢才是!


引用和评论

0 条评论