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]#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 *

 

 

 

   

   

转载于:https://www.cnblogs.com/xianfish/archive/2010/08/20/vim.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值