Vimにプラグインを入れる方法

ブログにも情報掲載してます♪

Vimはそのままでも十分な機能を備えているエディタですが、プラグインを導入することで、さらに便利にすることができます。
今回は、LinuxにVimプラグインを導入する方法を書いていきます。

1.プラグインを管理するdein.vimをダウンロードする
まず、プラグインを管理するためのdeinというプラグインを導入します。
下記のコマンドでgithubからdeinをダウンロードします。

$cd ~/.cache
$mkdir dein
$cd dein
$git clone https://github.com/Shougo/dein.vim


2..vimrcにスクリプトを書く

deinを有効にするため、下記のスクリプトを.vimrcに書きます。
.vimrcがない方は自分で作成します。

[.vimrcの作成 & スクリプトの追記]

$cd ~/
$vim .vimrc


[.vimrcの中身]

if &compatible
 set nocompatible
endif
" Add the dein installation directory into runtimepath
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim

if dein#load_state('~/.cache/dein')
 call dein#begin('~/.cache/dein')

 call dein#add('~/.cache/dein/repos/github.com/Shougo/dein.vim')
 call dein#add('Shougo/deoplete.nvim')
 if !has('nvim')
   call dein#add('roxma/nvim-yarp')
   call dein#add('roxma/vim-hug-neovim-rpc')
 endif

 call dein#end()
 call dein#save_state()
endif

filetype plugin indent on
syntax enable



3.vimエディタを一旦閉じ、vimを再度開いてdeinをインストールする
vimを開いたら、「 :call dein#install() 」を実行する。

$vim

:call dein#install()

これでdeinのインストールは完了です。

4.プラグインの追加
さて、いよいよ目的のプラグインのインストール作業になります。
先ほど2.で作成した.vimrcに導入したいプラグインのURLを追記します。
今回はIDEであるTrinityプラグインを導入してみたいと思います。
「 call dein#add('wesleyche/Trinity') 」を追記します。


if &compatible
 set nocompatible
endif
" Add the dein installation directory into runtimepath
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim

if dein#load_state('~/.cache/dein')
 call dein#begin('~/.cache/dein')

 call dein#add('~/.cache/dein/repos/github.com/Shougo/dein.vim')
 call dein#add('Shougo/deoplete.nvim')
 if !has('nvim')
   call dein#add('roxma/nvim-yarp')
   call dein#add('roxma/vim-hug-neovim-rpc')
   call dein#add('wesleyche/Trinity')
 endif

 call dein#end()
 call dein#save_state()
endif

filetype plugin indent on
syntax enable

追記ができたら、再度「 :call dein#install() 」を実行します。
これでプラグインのインストールは完了です。

この記事が気に入ったらサポートをしてみませんか?