【配置ctags】
假设你要编译的源代码目录位置为:/worksapce/weather
执行下面操作,生成tags标签文件:
[root@ericsson:/workspace/weather]#pwd /workspace/weather [root@ericsson:/workspace/weather]#ls dispacth.cpp dispacth.h main.cpp [root@ericsson:/workspace/weather]#ctags -R * [root@ericsson:/workspace/weather]#ls dispacth.cpp dispacth.h main.cpp tags
vim的配置文件有下面三个:
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
我本机配置vim是针对全局的,所以修改/etc/vimrc文件,在文件最后添加下面内容:
set tags=/workspace/weather/tags
如果有多个tags文件则用逗号隔开(tags文件名可以相同),设置完tags变量之后,使用如下:
[root@ericsson:/workspace/weather]#ls a.out dispacth.cpp dispacth.h main.cpp tags [root@ericsson:/workspace/weather]#vi -t ttcs
ttcs是函数名,被定义在main.cpp,如果ctags安装配置正确,则会自动跳到该函数定义处,如果有多个函数,则会出现一个列表。如果
出现:“E257: cstag: tag not found ”,建议重新到代码目录,运行:ctags -R *