Skip to content
Junegunn Choi edited this page Nov 26, 2017 · 4 revisions


Automatic installation

Place the following code in your .vimrc before plug#begin() call

if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC

Note that --sync flag is used to block the execution until the installer finishes.

(If you're behind an HTTP proxy, you may need to add --insecure option to the curl command. In that case, you also need to set $GIT_SSL_NO_VERIFY to true.)

Migrating from other plugin managers

Download plug.vim in autoload directory

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \

and update your .vimrc as needed.

With Vundle.vim Equivalent vim-plug configuration
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'junegunn/seoul256.vim'
Plugin 'junegunn/goyo.vim'
Plugin 'junegunn/limelight.vim'
call vundle#end()
filetype plugin indent on
syntax enable
call plug#begin('~/.vim/plugged')
Plug 'junegunn/seoul256.vim'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
call plug#end()

vim-plug does not require any extra statement other than plug#begin() and plug#end(). You can remove filetype off, filetype plugin indent on and syntax on from your .vimrc as they are automatically handled by plug#begin() and plug#end().

Since all the other major plugin managers store plugins in "bundle" directory, you might want to pass it to plug#begin() if you do not wish to reinstall plugins.

" For Mac/Linux users
call plug#begin('~/.vim/bundle')

" For Windows users
call plug#begin('~/vimfiles/bundle')

Unlike Vundle, vim-plug does not implicitly prepend vim-scripts/ to single-segment argument. So Plugin 'taglist.vim' in Vundle should be explicitly written as Plug 'vim-scripts/taglist.vim'. However, note that is no longer maintained.

Vim help

If you need Vim help for vim-plug itself (e.g. :help plug-options), register vim-plug as a plugin.

Plug 'junegunn/vim-plug'

Conditional activation

Use plain "if" statement to conditionally activate plugins:

if has('mac')
  Plug 'junegunn/vim-xmark'

The caveat is that when the condition is not met, PlugClean will try to remove the plugin. This can be problematic if you share the same configuration across terminal Vim, GVim, and Neovim.

" When started with plain Vim, the plugin is not registered
" and PlugClean will try to remove it
if has('nvim')
  Plug 'benekastah/neomake'

Alternatively, you can pass an empty on or for option so that the plugin is registered but not loaded by default depending on the condition.

Plug 'benekastah/neomake', has('nvim') ? {} : { 'on': [] }

A helper function can improve the readability.

function! Cond(cond, ...)
  let opts = get(a:000, 0, {})
  return a:cond ? opts : extend(opts, { 'on': [], 'for': [] })

" Looks better
Plug 'benekastah/neomake', Cond(has('nvim'))

" With other options
Plug 'benekastah/neomake', Cond(has('nvim'), { 'on': 'Neomake' })

Gist as plugin

vim-plug does not natively support installing small Vim plugins from Gist. But there is a workaround if you really want it.

Plug '',
    \ { 'as': 'xxx', 'do': 'mkdir -p plugin; cp -f *.vim plugin/' }

Loading plugins manually

With on and for options, vim-plug allows you to defer loading of plugins. But if you want a plugin to be loaded on an event that is not supported by vim-plug, you can set on or for option to an empty list, and use plug#load(names...) function later to load the plugin manually. The following example will load ultisnips and YouCompleteMe first time you enter insert mode.

" Load on nothing
Plug 'SirVer/ultisnips', { 'on': [] }
Plug 'Valloric/YouCompleteMe', { 'on': [] }

augroup load_us_ycm
  autocmd InsertEnter * call plug#load('ultisnips', 'YouCompleteMe')
                     \| autocmd! load_us_ycm
augroup END
Clone this wiki locally
You can’t perform that action at this time.