您的位置:首页 > 运维架构

ubuntu vi ctags cscope

2013-08-05 11:28 267 查看
安装vi

sudo apt-get install vim

sudo apt-get install cscope

sudo apt-get install ctags

然后在/etc/vim/vimrc 中添加

if has("cscope")

set cscopetag

set csto=0

if filereadable("cscope.out")
cs add cscope.out
" else add the database pointed to by environment variable
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif

set cscopeverbose
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>

endif

然后在项目文件夹下

find -name "*.c" > cscope.files(将c语言程序源代码的所有文件名加入到cscope.files中)

cscope -Rbkq (创建cscope.out cscope.po.out cscope.in.out)

然后每次都可以在vi内使用命令

要在下标模式

:find c main

:find s main

:find c main

首先执行ctags –R

然后执行vi –t tag
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: