博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Vim使用Vundle安装代码补全插件(YouCompleteMe)
阅读量:7032 次
发布时间:2019-06-28

本文共 3318 字,大约阅读时间需要 11 分钟。

安装 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, requiredfiletype off " required" set the runtime path to include Vundle and initializeset rtp+=~/.vim/bundle/Vundle.vimcall vundle#begin()" alternatively, pass a path where Vundle should install plugins"call vundle#begin('~/some/path/here')" let Vundle manage Vundle, requiredPlugin '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 linecall vundle#end() " requiredfiletype 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 cmak

然后切换到以下目录

cd ~/.vim/bundle/YouCompleteMe

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

./install.sh

配置 YouCompleteMe

 ~/.vimrc 中添加配置

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

到此,YouCompleteMe 已安装成功。

转载于:https://www.cnblogs.com/feiyuhuo/p/10274236.html

你可能感兴趣的文章
我的友情链接
查看>>
安装Redis的图形界面管理工具phpRedisAdmin
查看>>
Flash object和embed标签
查看>>
gtk与xlib之间相关连接
查看>>
解决ImportError: cannot import name HTTPSHandler
查看>>
paho-mqtt 文档翻译
查看>>
ubuntu11.10安装锐捷认证问题解决方案!
查看>>
linux(ubuntu server)下安装配置tomcat6
查看>>
crontab定时启动脚本,自动化配置
查看>>
批量修改外网密码
查看>>
ansible学习记录
查看>>
HA集群之五:
查看>>
图解字符串的朴素模式匹配算法
查看>>
Spring Boot整合MyBatis学习总结
查看>>
juniper ssl ***配置主机检测MAC功能
查看>>
liblinear 训练时去掉输出信息
查看>>
python3.4连接mysql数据库
查看>>
个人python开发环境搭建
查看>>
ELK5.5.0 集群部署以及体验使用插件X-pack
查看>>
防火线缆在建筑中的应用专题访谈
查看>>