vim插件管理器的安装和配置-windows

时间:2021-08-20 15:09:24

# vim插件管理器的安装和配置-windows

### 前言
-----------------------------
- vim做一框功能强大的编辑器,扩展功能令人称奇,插件机制非常灵活
- 本篇推荐两款vim的插件管理器vundle和vim-plug
- vundle是一款老款的插件管理工具
- vim-plug相对较新,特点是支持异步加载,相比vundle而言

### vundle
-----------------------------
#### 简介
-----------------------------
- vundle是开源项目
- [项目地址](https://github.com/VundleVim/Vundle.vim)

#### 先决条件
-----------------------------
- git
- [下载地址](https://gitforwindows.org/)
- curl
- [下载地址](https://curl.haxx.se/download.html)
- 配置下环境变量

#### 安装
-----------------------------
- `git clone https://github.com/VundleVim/Vundle.vim.git %USERPROFILE%/.vim/bundle/Vundle.vim`
- %USERPROFILE% 当前用户路径

#### 配置
-----------------------------
- 在`_vimrc`配置文件中添加如下内容

```
set nocompatible " 去掉vim的扩展,和vi保持兼容
filetype off " 关闭文件类型检测

" set the runtime path to include Vundle and initialize
" 设置运行时路径包括Vundle和初始化
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required 让Vundle管理Vundle
Plugin 'VundleVim/Vundle.vim'

" All of your Plugins must be added before the following line
call vundle#end() " required

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
```

### vim-plug
-----------------------------
#### 简介
-----------------------------
- vim-plug是开源项目
- [项目地址](https://github.com/junegunn/vim-plug)

#### 安装
-----------------------------
- 下载plug.vim放在`auload`目录下

#### 配置
-----------------------------
- 在`_vimrc`配置文件中添加如下内容
```
call plug#begin('~/.vim/plugged')

" Make sure you use single quotes

" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
" 一款文本对齐的插件,非常神奇
Plug 'junegunn/vim-easy-align'

" Any valid git URL is allowed
" github公告板,刷帖
Plug 'https://github.com/junegunn/vim-github-dashboard.git'

" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'

" On-demand loading 按需加载
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }

" Using a non-master branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }

" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }

" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }

" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }

" Initialize plugin system
call plug#end()
```

### vim脚本插件
-----------------------------
- [vim脚本仓库](http://vim-scripts.org/vim/scripts.html)
- [vim脚本仓库,比较好用](https://vimawesome.com/)