linux下vim设置—-ctag

【前言】

ctags是vim的一个非常有用的插件,可以大大提高程序编码(C、C++)的效率,比如快速调整到函数、变量定义处等等常用

功能,更详细的功能,自行百度。

【目的】

在RHEL 5上面安装配置vim插件ctags

【前提条件】

vim已经安装

【安装ctags】

1、首先确定自己是否已经安装了ctag:

[root@ericsson:~]#which ctags/usr/bin/ctags

如果结果如上,证明已经安装了该插件,则跳过下面步骤。

如果找不到,极有可能ctags还没安装,安装步骤如下:

1、下载ctags:http://ctags.sourceforge.net

2、上传到linux,解压,假设目录为:/tmp/ctags

3、确保/tmp/ctags/configure文件有执行权限,执行该文件:/tmp/ctags/configure

4、执行命令:make;make install

如果顺利,上面4个步骤可以成功安装ctags

【配置ctags】

假设你要编译的源代码目录位置为:/worksapce/weather

执行下面操作,生成tags标签文件:

[root@ericsson:/workspace/weather]#pwd/workspace/weather[root@ericsson:/workspace/weather]#lsdispacth.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]#lsa.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 *

原文链接: https://www.cnblogs.com/xianfish/archive/2010/08/20/vim.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/14148

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月7日 下午1:37
下一篇 2023年2月7日 下午1:38

相关推荐