安装 Vundle

它的使用方法很简单,安装一个插件只需要在 ~/.vimrc 按照规则中添加 Plugin 的名称,某些需要添加路径,之后在 Vim 中使用:PluginInstall既可以自动化安装。

1、先新建目录

mkdir ~/.vim/bundle/Vundle.vim

2、git 克隆 Vundle 工程到本地

git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim

3、修改 ~/.vimrc 配置 Plugins。在 ~/.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. " 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

4、进入 vim 运行命令

:PluginInstall

Vundle 命令

# 安装插件
:BundleInstall
# 更新插件
:BundleUpdate
# 清除不需要的插件
:BundleClean
# 列出当前的插件
:BundleList
# 搜索插件
:BundleSearch

注意

插件配置不要在 call vundle#end() 之前,不然插件无法生效
如果配置错误,需要重新配置后,在vim中运行命令 :PluginInstall

使用 Vundle 安装 YouCompleteMe

在 ~/.vimrc 中添加如下内容 位置在call vundle#begin()call vundle#end()之间

Bundle 'Valloric/YouCompleteMe'

在vim中运行以下命令就会自行安装,安装时间有点长,请耐心等待

:BundleInstall

安装完成后需要编译 YouCompleteMe

编译过程需要CMake,没有安装CMake可使用以下命令进行安装

sudo apt install cmake

然后切换到以下目录

cd ~/.vim/bundle/YouCompleteMe 

最后输入以下命令即可(默认支持python)

./install.sh

配置 YouCompleteMe

在 ~/.vimrc 中添加配置

" 自动补全配置
set completeopt=longest,menu "让Vim的补全菜单行为与一般IDE一致(参考VimTip1228)
autocmd InsertLeave * if pumvisible() == |pclose|endif "离开插入模式后自动关闭预览窗口
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" "回车即选中当前项
"上下左右键的行为 会显示其他信息
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>" "youcompleteme 默认tab s-tab 和自动补全冲突
"let g:ycm_key_list_select_completion=['<c-n>']
let g:ycm_key_list_select_completion = ['<Down>']
"let g:ycm_key_list_previous_completion=['<c-p>']
let g:ycm_key_list_previous_completion = ['<Up>']
let g:ycm_confirm_extra_conf= "关闭加载.ycm_extra_conf.py提示 let g:ycm_collect_identifiers_from_tags_files= " 开启 YCM 基于标签引擎
let g:ycm_min_num_of_chars_for_completion= " 从第2个键入字符就开始罗列匹配项
let g:ycm_cache_omnifunc= " 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_seed_identifiers_with_syntax= " 语法关键字补全
nnoremap <F5> :YcmForceCompileAndDiagnostics<CR> "force recomile with syntastic
"nnoremap <leader>lo :lopen<CR> "open locationlist
"nnoremap <leader>lc :lclose<CR> "close locationlist
inoremap <leader><leader> <C-x><C-o>
"在注释输入中也能补全
let g:ycm_complete_in_comments =
"在字符串输入中也能补全
let g:ycm_complete_in_strings =
"注释和字符串中的文字也会被收入补全
let g:ycm_collect_identifiers_from_comments_and_strings = nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> " 跳转到定义处

到此,YouCompleteMe 已安装成功。

Vim使用Vundle安装代码补全插件(YouCompleteMe)的更多相关文章

  1. Windows 10环境安装VIM代码补全插件YouCompleteMe

    Windows 10环境安装VIM代码补全插件YouCompleteMe 折腾一周也没搞定Windows下安装VIM代码补全插件YouCompleteMe,今天在家折腾一天总算搞定了.关键问题是在于P ...

  2. 【转】Vim自动补全插件----YouCompleteMe安装与配置

    原文网址:http://www.cnblogs.com/zhongcq/p/3630047.html 使用Vim编写程序少不了使用自动补全插件,在Linux下有没有类似VS中的Visual Assis ...

  3. Vim自动补全插件----YouCompleteMe安装与配置

    Vim自动补全插件----YouCompleteMe安装与配置 使用Vim编写程序少不了使用自动补全插件,在Linux下有没有类似VS中的Visual Assist X这么方便快捷的补全插件呢?以前用 ...

  4. 如何安装vim自动补全插件YouCompleteMe(YCM)

    Vim是全平台上一个高度可拓展的编辑器.它本身只是一个简陋的编辑器,但是因为有各种插件而变得强大.使用Vim编写代码就不免遇到代码补全的问题.常用的代码补全插件有两个:日本人shougo写的neoco ...

  5. Sublime text代码补全插件(支持Javascript、JQuery、Bootstrap框架)

    Sublime text代码补全插件(支持Javascript.JQuery.Bootstrap框架)   插件名称:javascript-API-Completions 支持Javascript.J ...

  6. MaxScript代码补全插件

    MaxScript代码补全插件 作者Nik,原文发布于ScriptSpot 安装后max自带脚本编辑器会有自动补全,效果如下:

  7. jupyter lab最强代码补全插件

    1 简介 提起kite相信不少朋友都有印象,它是一个功能非常强大的代码补全工具,目前可用于Python与javascript,为许多知名的编辑器譬如Vs Code.Pycharm提供对应的插件. 图1 ...

  8. CentOS7 Vim自动补全插件----YouCompleteMe安装与配置

    最近刚装了新系统CentOS7,想要把编码环境配置一下,使用Vim编写程序少不了使用自动补全插件,我以前用的是neocomplcache+code_complete+omnicppcomplete.但 ...

  9. vim安装自动补全插件

    1. 先安装Pathogen,以便后续的插件安装. 打开网址https://github.com/tpope/vim-pathogen可以查看具体安装方法. a.创建目标并安装: mkdir -p ~ ...

随机推荐

  1. ubuntu下安装/卸载vmware虚拟机

    1.下载vmware(官网下载试用版,试用版输入序列号后即为专业版,序列号网上搜,很多) 2.下载后安装(命令行) 1)cd进你下载的位置 1.1)下载的文件名字为:VMware-Workstatio ...

  2. mysql之索引查询1

    一 备份数据 备份库: mysqldump:拷贝数据 --database:数据库 基本语法是:mysqldump -h服务器名 -u用户名 -p密码 --database 库名 > 备份路径. ...

  3. 836. Rectangle Overlap

    class Solution { public: bool isRectangleOverlap(vector<int>& rec1, vector<int>& ...

  4. 2018.12.12 codeforces 931E. Game with String(概率dp)

    传送门 感觉这题难点在读懂题. 题目简述:给你一个字符串s,设将其向左平移k个单位之后的字符串为t,现在告诉你t的第一个字符,然后你可以另外得知t的任意一个字符,求用最优策略猜对k的概率. 解析: 预 ...

  5. C# Bitmap长宽参数构造的图片对象的每个像素ARGB都是0

    var img = new Bitmap(100 , 100); for (int i = 0; i < img.Width; i++) {   for (int j = 0; j < i ...

  6. 容器监控告警方案(cAdvisor + nodeExporter + alertmanager + prometheus +grafana)

    一.prometheus基本架构 Prometheus 是一套开源的系统监控报警框架.它启发于 Google 的 borgmon 监控系统,由工作在 SoundCloud 的 google 前员工在 ...

  7. 构造函数的prototype和constructor属性

    Car.prototype = { name:'BMW', height:1400, long:4900 } function Car(color,owner){ this.color = color ...

  8. jdk1.6的配置

    执行下列命令安装jdk1.7 /usr/lib/jvm$ sudo apt-get install openjdk-7-jdk openjdk-7-jre 会得到下面这两个文件: 查看当前jdk版本: ...

  9. RAW转换成RGB

    clc; clear; close all; [filename,pathname]=uigetfile({'*.*','All Files (*.*)'},'Pick a file'); file ...

  10. 行转列group_concat()函数妙用

    测试环境准备: mysql> create table test01(name varchar(20),address varchar(20)); Query OK, 0 rows affect ...