比较土,才开始用ctags,挺好用,对于C++代码有良好的支持。基本用法:先安装ctags,
wget http://prdownloads.sourceforge.net/ctags/ctags-5.6.tar.gz tar zxvf ctags-5.6.tar.gz cd ctags-5.6 ./configure && make && sudo make install cd /home/my/code/top/src //进入你的源码目录 [/home/my/code/top/src]$ ctags -R //创建tags然后配置ctags:
vi ~/.vimrc加入一句话:
这句话的意思是先在当前目录找tags文件,如果找不到则逐层地向顶层目录找,直到找到为止。等价代码: function SetTags() let curdir = getcwd() while !filereadable("tags") && getcwd() != "/" cd .. endwhile if filereadable("tags") execute "set tags=" . getcwd() . "/tags" endif execute "cd " . curdir endfunction call SetTags()set tags=tags;/
好了。现在就开始使用吧~ 打开一个源码,进入命令模式搜索一个函数名字:
:ja my_fun_name
就能跳到对应函数位置。看完后希望跳回原处,只需要不断CTRL+o即可往回跳转。
ctaglist也是个很强大的工具,作用类似于函数浏览器。还没用过,等后面需要的时候再试试~