记一次通过vim-plug安装tagbar过程

本文详细介绍如何在Vim环境中配置Tagbar插件,并解决在安装过程中遇到的依赖问题,包括Ctags的安装与配置,确保代码导航功能正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通过vim-plug安装tarbar

安装好vim-plug后,在.vimrc中添加

call plug#begin('~/.vim/plugged')
Plug 'majutsushi/tagbar'
call plug#end()

然后执行

source ~/.vimrc
:PlugInstall

然后去cpp文件使用tagba,执行

:TagbarToggle

出现错误

Please download Exuberant Ctags from ctags.sourceforge.net and install it in a directory in your $PATH or set g:tagbar_ctags_bin.

原理安装tagbar需要依赖

  • Vim >= 7.3.1058 or any version of NeoVim.
  • Exuberant Ctags >= 5.5, or (highly recommended) any version of Universal Ctags which is a currently maintained fork of Exuberant Ctags with many bugfixes, support for many more formats, and proper Unicode support. Some additional formats can also be handled by other providers such as jsctags, phpctags, or others.

我的vim是vim8.所以,我还需要去安装Ctgas。

首先git Ctgas

git clone https://github.com/universal-ctags/ctags.git

下载好后进入文件夹中

cd ctags

然后执行以下命令

$ ./autogen.sh
$ ./configure --prefix=/where/you/want # defaults to /usr/local
$ make
$ make install # may require extra privileges depending on where to install

又出现错误

执行./autogen.sh时

  • type autoreconf ./autogen.sh: 第 5 行:type: autoreconf: 未找到 + exit 1

解决办法

yum  -y install install autoconf automake libtool

执行make install # may require extra privileges depending on where to install时

/usr/bin/install: 无法删除"/usr/local/bin/ctags": 权限不够
/usr/bin/install: 无法删除"/usr/local/bin/readtags": 权限不够

解决办法,进入root用户,执行

chmod -R 777 /usr/local/bin

给其权限。

最后可以使用tagbar了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值