版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/heyuqian_csdn/article/details/78832099
配置好cscope之后,执行cscope find命令,总是提示file does not exist。如下是我的配置文件vimrc
set number
set mouse=a
set tags=tags;
set autochdir
map <F12> :!ctags -R .<CR>
map <F11> :!cscope -Rbq <CR>
配置非常少,cscope只是配置了快捷键,后来发现是由于设置了“set autochdir”,切换到子目录会自动重新设置路径,导致路径出错,删除后解决问题。
Ps:我的系统是centos7,通过yum安装cscope,会自动配置cscope加载cscope.out,在/etc/viminfo中
if has("cscope") && filereadable("/usr/bin/cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add $PWD/cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif
如下是我的vim环境安装过程:
1、安装vim,ctags,cscope,bundle
yum install vim ctags cscope
mkdir -p ~/.vim/bundle
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
2、修改~/.vimrc配置文件
[vagrant@localhost rtl8812au]$ cat ~/.vimrc
set number
set mouse=a
set tags=tags;
map <F12> :!ctags -R .<CR>
map <F11> :!cscope -Rbq <CR>
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
filetype plugin indent on
"安装插件Ctrlp
Bundle 'kien/ctrlp.vim'
"设置ctrlp的快捷方式 ctrp
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn|rvm)$',
\ 'file': '\v\.(exe|so|dll|zip|tar|tar.gz|pyc)$',
\ }
"默认使用全路径搜索,置1后按文件名搜索,准确率会有所提高,可以用<C-d>进行切换
let g:ctrlp_by_filename = 1
"默认不使用正则表达式,置1改为默认使用正则表达式,可以用<C-r>进行切换
let g:ctrlp_regexp = 0
let g:ctrlp_working_path_mode = 0
let g:ctrlp_match_window_bottom = 1
"修改QuickFix窗口显示的最大条目数
let g:ctrlp_max_height = 15
let g:ctrlp_match_window_reversed = 0
"设置MRU最大条目数为500
let g:ctrlp_mruf_max = 500
let g:ctrlp_follow_symlinks = 1
3、安装ctrlp,ctrlp是通过bundle插件安装的,打开vim,执行:BundleInstall即可