vim插件管理器
一.插件介绍
1.1 插件管理器简介
插件管理器便于vim插件配置使用的一种管理器。可以通过配置自动从远端获取并安装插件,支持插件自动化脚本调用来自动生成配置文件。
1.2 插件管理器推荐
能够拥有一款好用的插件管理器是vimer的福音。市面上有很多种不同的插件管理器,其实原理都是一样的,通过固定的插件名称拼接url来解析获取远端git上的插件代码(例如github),同时提供了一些配置可以自动调用例如./install.sh等脚本文件。vimer可以很方便的利用插件名获取插件。现在用得较多的插件管理器有vim-plug以及Vundle,当然我个人还是比较喜欢vim-plug,因为它是并行下载插件,相对较快,而且 我用习惯了。
二.插件使用
在官网上有vim插件使用的详细例子,我就拿过来作为简单的例子,同时网上也有一些好用的插件,接下来我们慢慢更新插件的用法以及一些好玩的设置
2.1 vim-plug
2.1.1下载方法
- linux
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
- window
md ~\vimfiles\autoload $uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' (New-Object Net.WebClient).DownloadFile( $uri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath( "~\vimfiles\autoload\plug.vim" ) )
2.1.2 使用方法
-
配置在.vimrc文件里 .vimrc在~目录下,也就是linux的家目录下
" Specify a directory for plugins " - For Neovim: stdpath('data') . '/plugged' " - Avoid using standard Vim directory names like 'plugin' 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 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' } " Unmanaged plugin (manually installed and updated) Plug '~/my-prototype-plugin' " Initialize plugin system call plug#end()
2.1.3 执行命令
-
PlugInstall 下载 PlugUpdate 更新
2.2 Vundle
2.2.1 安装
- linux
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
- window
也是在家目录下一个bundle里面clone一个Vundle.vim 原理一样的
2.2.2 使用方法
-
配置在.vimrc 文件下,区别是多了一行指定Vundle.vim文件的代码
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