Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Jan Edmund Lazo edited this pageMar 26, 2021 ·12 revisions

Tips

Automatic installation

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

let data_dir=has('nvim') ?stdpath('data') .'/site' :'~/.vim'ifempty(glob(data_dir .'/autoload/plug.vim'))silentexecute'!curl -fLo'.data_dir.'/autoload/plug.vim --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'autocmdVimEnter* PlugInstall--sync |source$MYVIMRCendif

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

HTTP proxy issues⚠️

If you're behind an HTTP proxy and your proxy does not have TLS/SSL certificates required for Github or if Github has expired TLS/SSL certificates, 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.

Resort to this only if git cannot get updated certificates or if Github has TLS/SSL issues.

Automatic installation of missing plugins

You can even go a step further and make:PlugInstall run on startup if there are any missing plugins.

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

" Install vim-plug if not foundifempty(glob('~/.vim/autoload/plug.vim'))silent!curl-fLo~/.vim/autoload/plug.vim--create-dirs\https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vimendif" Run PlugInstall if there are missing pluginsautocmdVimEnter*iflen(filter(values(g:plugs),'!isdirectory(v:val.dir)'))\| PlugInstall--sync |source$MYVIMRC\|endif

Note that this may increase the startup time of Vim.

Install plugins on the command line

# vimvim -es -u vimrc -i NONE -c"PlugInstall" -c"qa"# neovimnvim -es -u init.vim -i NONE -c"PlugInstall" -c"qa"

-u is used here to force (n)vim to read only the given vimrc. See:h startup.-i is used here to skipviminfo (vim) orshada (nvim). Reduce theruntimepath via--cmd to speed up vim-plug. Add-V to debug vim-plug if there are errors.

Migrating from other plugin managers

Download plug.vim inautoload directory

curl -fLo~/.vim/autoload/plug.vim --create-dirs \    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

and update your .vimrc as needed.

With Vundle.vimEquivalent vim-plug configuration
filetype offset rtp+=~/.vim/bundle/Vundle.vimcall vundle#begin()Plugin 'VundleVim/Vundle.vim'Plugin 'junegunn/seoul256.vim'Plugin 'junegunn/goyo.vim'Plugin 'junegunn/limelight.vim'call vundle#end()filetype plugin indent onsyntax 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 thanplug#begin() andplug#end().You can removefiletype off,filetype plugin indent on andsyntax on from your.vimrc as they are automatically handled byplug#begin() andplug#end().

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

" For Mac/Linux userscallplug#begin('~/.vim/bundle')" For Windows userscallplug#begin('~/vimfiles/bundle')

Unlike Vundle, vim-plug does not implicitly prependvim-scripts/ to single-segment argument. SoPlugin 'taglist.vim' in Vundle should be explicitly written asPlug 'vim-scripts/taglist.vim'. However, note that vim-scripts.org 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:

ifhas('mac')  Plug'junegunn/vim-xmark'endif

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 itifhas('nvim')  Plug'benekastah/neomake'endif

Alternatively, you can pass an emptyon orfor 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, {})returna:cond ? opts :extend(opts, {'on': [],'for': [] })endfunction" Looks betterPlug'benekastah/neomake',Cond(has('nvim'))" With other optionsPlug'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'https://gist.github.com/952560a43601cd9898f1.git',\{'as':'xxx','do':'mkdir -p plugin; cp -f *.vim plugin/' }

Loading plugins manually

Withon andfor 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 seton orfor option to an empty list, and useplug#load(names...) function later to load the plugin manually. The following example will loadultisnips andYouCompleteMe first time you enter insert mode.

" Load on nothingPlug'SirVer/ultisnips', {'on': [] }Plug'Valloric/YouCompleteMe', {'on': [] }augroupload_us_ycmautocmd!autocmdInsertEnter*callplug#load('ultisnips','YouCompleteMe')\|autocmd! load_us_ycmaugroupEND
Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp