使用Vundle安装YouCompleteMe

使用Vundle安装YouCompleteMe

Linux x64系统

1. Vundle简介

Vundle是Vim bundle的缩写,是Vim插件管理器。

Vundle允许你…

  • 跟踪并配置您的插件.vimrc

  • 安装配置的插件(又名脚本/包)

  • 更新配置的插件

  • 按名称搜索所有可用的Vim脚本

  • 清理未使用的插件

  • 使用交互模式在单个按键中运行上述操作

Vundle自动…

  • 管理已安装脚本的运行时路径
  • 安装和更新后重新生成帮助标签

2. 安装Vundle

使用git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim命令下载源码,默认安装在/.vim/bundle/vundle下;如果/.vim/bundle/vundle不存在,使用

madir -p /.vim/bundle/vundle来建立目录;

vim ~/. vimrc打开vimrc进行配置, 在vimrc头部添加如下配置,根据需要修改插件(文末有中文版),保存。

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

set number

3. 安装需要的插件

将想要安装的插件,按照上文代码中的示例填写,如:GitHub上的插件格式为 Plugin ‘用户名/插件仓库名’

填写在vundle#begin和vundle#end之间就可以。

3.1

保存之后,有两种方法安装插件。

  • 启动vim ,再在vim中运行 :PluginInstall
  • 通过命令行直接安装 vim +PluginInstall +qall

安装完成之后,插件就可以使用了。

3.2 YouCompleteMe

在vundle#begin和vundle#end之间填写:

Plugin 'ycm-core/YouCompleteMe'

当然也可以git clone git 源代码到~/.vim/bundle/YouCompleteMe

**注:**YCM不小,轻耐心等待。在墙内的速度可能会慢一点。

配置好系统的 Python 环境以及 CMake

以下是针对 Ubuntu 系统的环境配置,这里主要需要给系统安装配置好 cmake 以及 python,具体命令如下:

因为本文使用Ubuntu18.04所以直接运行如下命令

sudo apt install build-essential cmake python3-dev

以下忽略

# install CMake
#sudo apt-get install build-essential cmake
# install Python
#sudo apt-get install python-dev python3-dev

安装

运行 .install.py 脚本安装语言支持。这里为了方便,我们选择安装所有语言支持,如果需要只安装特定的语言支持,可以参考官方文档。

cd ~/.vim/bundle/YouCompleteMe
python3 install.py --all

参考:https://github.com/ycm-core/YouCompleteMe

4. 移除不需要的插件

  • 编辑.vimrc文件移除的你要移除的插件所对应的plugin那一行。
  • 保存退出当前的vim
  • 重新打开vim,输入命令BundleClean。
5. 其他常用命令

更新插件BundleUpdate
列出所有插件BundleList
查找插件BundleSearch

" 常用的命令
:PluginList - 列出所有已配置的插件
:PluginInstall - 安装插件,追加 ! 用以更新或使用 :PluginUpdate
:PluginSearch foo - 搜索 foo ; 追加 ! 清除本地缓存
:PluginClean - 清除未使用插件,需要确认; 追加 ! 自动批准移除未使用插件

6. 常见例子

see Examples

PS: reference 4 是一个很炫酷的配置方案。

Reference:

  1. Vundle
  2. YouCompleteMe
  3. vim插件管理器:Vundle的介绍及安装(很全)
  4. Vim的终极配置方案,完美的写代码界面! ——.vimrc
set nocompatible              " 去除VI一致性,必须要添加
filetype off                  " 必须要添加

" 设置包括vundle和初始化相关的runtime path
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" 另一种选择, 指定一个vundle安装插件的路径
"call vundle#begin('~/some/path/here')

" 让vundle管理插件版本,必须
Plugin 'VundleVim/Vundle.vim'

" 以下范例用来支持不同格式的插件安装.
" 请将安装插件的命令放在vundle#begin和vundle#end之间.
" Github上的插件
" 格式为 Plugin '用户名/插件仓库名'
Plugin 'tpope/vim-fugitive'
" 来自 http://vim-scripts.org/vim/scripts.html 的插件
" Plugin '插件名称' 实际上是 Plugin 'vim-scripts/插件仓库名' 只是此处的用户名可以省略
Plugin 'L9'
" 由Git支持但不再github上的插件仓库 Plugin 'git clone 后面的地址'
Plugin 'git://git.wincent.com/command-t.git'
" 本地的Git仓库(例如自己的插件) Plugin 'file:///+本地插件仓库绝对路径'
Plugin 'file:///home/gmarik/path/to/plugin'
" 插件在仓库的子目录中.
" 正确指定路径用以设置runtimepath. 以下范例插件在sparkup/vim目录下
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" 安装L9,如果已经安装过这个插件,可利用以下格式避免命名冲突
Plugin 'ascenator/L9', {'name': 'newL9'}

" 你的所有插件需要在下面这行之前
call vundle#end()            " 必须
filetype plugin indent on    " 必须 加载vim自带和插件相应的语法和文件类型相关脚本
" 忽视插件改变缩进,可以使用以下替代:
"filetype plugin on
"
" 常用的命令
" :PluginList       - 列出所有已配置的插件
" :PluginInstall  	 - 安装插件,追加 `!` 用以更新或使用 :PluginUpdate
" :PluginSearch foo - 搜索 foo ; 追加 `!` 清除本地缓存
" :PluginClean      - 清除未使用插件,需要确认; 追加 `!` 自动批准移除未使用插件
"
" 查阅 :h vundle 获取更多细节和wiki以及FAQ
" 将你自己对非插件片段放在这行之后
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

烤粽子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值