一、简介
Vundle是vim上的插件管理器,2019年比较新的有 vim-plug,当然,你也可以使用 dein + dein-ui, dein 相比 vim-plug 支持更多的延迟加载模式和插件hooks,让插件以及插件配置管理更加简单。
Vundle使用时只需要在.vimrc添加上控件名,Vundle可以帮我们下载到插件文件夹/Users/{username}/.vim/bundle中。
有一个vim插件的资源网站,可以在那里搜索:vim script
clone Vundle ,配置安装时请输入以下命令:
注意:默认安装在/.vim/bundle/vundle目录下
1 mkdir ~/.vim 2 mkdir ~/.vim/bundle 3 cd ~/.vim/bundle 4 git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
二、配置说明
插件有三种类型:
- Github上vim-scripts仓库的插件
- Github上非vim-scripts仓库的插件
- 不在Github上的插件
对于不同的插件,vundle自动管理和下载插件的时候,有不同的地址填写方法,有如下三类:
- 在Github上vim-scripts用户下的仓库,只需要写出repos(仓库)名称
- 在Github其他用户下的repos, 需要写出"用户名/repos名"
- 不在Github上的插件,需要写出git全路径
修改配置文件~/.vimrc
"-----------------------------------Vim插件管理工具Start----------------------------------- " 去除VI一致性,必须要添加 set nocompatible filetype off " set the runtime path to include Vundle and initialize " 设置包括vundle和初始化相关的runtime path set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins " 另一种选择, 指定一个vundle安装插件的路径 "call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required " 让vundle管理插件版本,必须 Plugin 'VundleVim/Vundle.vim' " The following are examples of different formats supported. " Keep Plugin commands between vundle#begin/end. " plugin on GitHub repo " 以下范例用来支持不同格式的插件安装. " 请将安装插件的命令放在vundle#begin和vundle#end之间. " Github上的插件 " 格式为 Plugin '用户名/插件仓库名' Plugin 'tpope/vim-fugitive' " plugin from http://vim-scripts.org/vim/scripts.html " 来自 http://vim-scripts.org/vim/scripts.html 的插件 " Plugin '插件名称' 实际上是 Plugin 'vim-scripts/插件仓库名' 只是此处的用户名可以省略 Plugin 'L9' " Git plugin not hosted on GitHub " 由Git支持但不再github上的插件仓库 Plugin 'git clone 后面的地址' Plugin 'git://git.wincent.com/command-t.git' " git repos on your local machine (i.e. when working on your own plugin) " 本地的Git仓库(例如自己的插件) Plugin 'file:///+本地插件仓库绝对路径' 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. " 插件在仓库的子目录中. " 正确指定路径用以设置runtimepath. 以下范例插件在sparkup/vim目录下 Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} Plugin 'MarcWeber/vim-addon-mw-utils' Plugin 'tomtom/tlib_vim' Plugin 'garbas/vim-snipmate' Plugin 'davidhalter/jedi-vim' Plugin 'nvie/vim-flake8' Plugin 'klen/python-mode' Plugin 'google/vim-maktaba' Plugin 'google/vim-codefmt' Plugin 'google/vim-glaive' augroup autoformat_settings autocmd FileType bzl AutoFormatBuffer buildifier autocmd FileType c,cpp,proto,javascript AutoFormatBuffer clang-format autocmd FileType dart AutoFormatBuffer dartfmt autocmd FileType go AutoFormatBuffer gofmt autocmd FileType gn AutoFormatBuffer gn autocmd FileType html,css,sass,scss,less,json AutoFormatBuffer js-beautify autocmd FileType java AutoFormatBuffer google-java-format autocmd FileType python AutoFormatBuffer yapf " Alternative: autocmd FileType python AutoFormatBuffer autopep8 autocmd FileType vue AutoFormatBuffer prettier augroup END " Install L9 and avoid a Naming conflict if you've already installed a " different version somewhere else. " 安装L9,如果已经安装过这个插件,可利用以下格式避免命名冲突 Plugin 'ascenator/L9', {'name': 'newL9'} " All of your Plugins must be added before the following line " 你的所有插件需要在下面这行之前(必须) call vundle#end() " requiredfiletype plugin indent on " required " 必须 加载vim自带和插件相应的语法和文件类型相关脚本 filetype plugin indent on " 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 " ------------------------中文-------------------------- " 常用的命令 " :PluginList - 列出所有已配置的插件 " :PluginInstall - 安装插件,追加 `!` 用以更新或使用 :PluginUpdate " :PluginSearch foo - 搜索 foo ; 追加 `!` 清除本地缓存 " :PluginClean - 清除未使用插件,需要确认; 追加 `!` 自动批准移除未使用插件 " " 查阅 :h vundle 获取更多细节和wiki以及FAQ " 将你自己对非插件片段放在这行之后 "-----------------------------------Vim插件管理工具End-------------------------------------
然后输入vim命令,在vim界面输入:PluginInstall 安装插件
在vim界面输入:PluginList 查看已安装插件
安装需要的插件
将想要安装的插件,按照地址填写方法,将地址填写在vundle#begin和vundle#end之间就可以
保存之后,有两种方法安装插件。
(1) 运行 vim ,再运行 :PluginInstall
$vim
:PlugInstall
(2) 通过命令行直接安装 vim +PluginInstall +qall
vim +PluginInstall +qall
安装完成之后,插件就可以使用。
三、Vundle常用命令
输入vim命令,在vim界面输入:
- :BundleList -列举出列表中(.vimrc中)配置的已安装的所有插件
- :BundleInstall -安装列表中全部插件
- :BundleInstall! -更新列表中全部插件
- :BundleUpdate -更新插件
- :BundleSearch -查找插件
- :BundleSearch foo -查找foo插件
- :BundleSearch! foo -刷新foo插件缓存
- :BundleClean -清除列表中没有的插件
- :BundleClean! -清除列表中没有的插件

浙公网安备 33010602011771号