方法一 :vim 插件——autoload_cscope.vim
步骤:
插件下载地址:autoload_cscope.vim
下载之后,讲autoload_cscope.vim
放到~/.vim/plugin
目录下,如果没有该目录那就创建一个,重新打开终端即可。
优点:
有人维护(不过貌似很久没有更新了),稳定。
缺点:
只对*.c/*.h
等代码文件有效,对一些辅助文件(例如Makefile)无效。
补充:
下面贴上代码,方便下载不成功时,可以直接复制到空文件中,并改名为autoload_cscope.vim
,并按上述方法处理即可。
" Vim global plugin for autoloading cscope databases.
" Last Change: Wed Jan 26 10:28:52 Jerusalem Standard Time 2011
" Maintainer: Michael Conrad Tadpol Tilsra <tadpol@tadpol.org>
" Revision: 0.5
if exists("loaded_autoload_cscope")
finish
endif
let loaded_autoload_cscope = 1
" requirements, you must have these enabled or this is useless.
if( !has('cscope') || !has('modify_fname') )
finish
endif
let s:save_cpo = &cpo
set cpo&vim
" If you set this to anything other than 1, the menu and macros will not be
" loaded. Useful if you have your own that you like. Or don't want my stuff
" clashing with any macros you've made.
if !exists("g:autocscope_menus")
let g:autocscope_menus = 1
endif
"==
" windowdir
" Gets the directory for the file in the current window
" Or the current working dir if there isn't one for the window.
" Use tr to allow that other OS paths, too
function s:windowdir()
if winbufnr(0) == -1
let unislash = getcwd()
else
let unislash = fnamemodify(bufname(winbufnr(0)), '