— Vim — 1 min read
Vimのバージョンを確認。
$ vim --versionVIM - Vi IMproved 8.1 (2018 May 18, compiled Jun  5 2020 21:30:37)macOS versionIncluded patches: 1-503, 505-680, 682-2292Vimのプラグインマネージャdein.vimを導入。
deinのインストール先フォルダを~/.vim/deinにする。
$ mkdir ~/.vim/dein$ curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh$ sh ./installer.sh ~/.vim/deinInstall to "/Users/user/.vim/dein/repos/github.com/Shougo/dein.vim"...git is /usr/bin/gitBegin fetching dein...Cloning into '/Users/user/.vim/dein/repos/github.com/Shougo/dein.vim'...remote: Enumerating objects: 5530, done.remote: Total 5530 (delta 0), reused 0 (delta 0), pack-reused 5530Receiving objects: 100% (5530/5530), 1.07 MiB | 1.15 MiB/s, done.Resolving deltas: 100% (3153/3153), done.Done.Please add the following settings for dein to the top of your vimrc (Vim) or init.vim (NeoVim) file:"dein Scripts-----------------------------if &compatible  set nocompatible               " Be iMprovedendif" Required:set runtimepath+=/Users/user/.vim/dein/repos/github.com/Shougo/dein.vim" Required:if dein#load_state('/Users/user/.vim/dein')  call dein#begin('/Users/user/.vim/dein')  " Let dein manage dein  " Required:  call dein#add('/Users/user/.vim/dein/repos/github.com/Shougo/dein.vim')  " Add or remove your plugins here like this:  "call dein#add('Shougo/neosnippet.vim')  "call dein#add('Shougo/neosnippet-snippets')  " Required:  call dein#end()  call dein#save_state()endif" Required:filetype plugin indent onsyntax enable" If you want to install not installed plugins on startup."if dein#check_install()"  call dein#install()"endif"End dein Scripts-------------------------Done.Complete setup dein!指示に従って、~/.vimrcにdeinの設定を追記。
1if &compatible2  set nocompatible               " Be iMproved3endif45set runtimepath+=~/.vim/dein/repos/github.com/Shougo/dein.vim67if dein#load_state('~/.vim/dein')8  call dein#begin('~/.vim/dein')910  " Let dein manage dein11  call dein#add('~/.vim/dein/repos/github.com/Shougo/dein.vim')1213  " Add or remove your plugins here like this:14  "call dein#add('Shougo/neosnippet.vim')15  "call dein#add('Shougo/neosnippet-snippets')1617  call dein#end()18  call dein#save_state()19endif2021filetype plugin indent on22syntax enable2324" If you want to install not installed plugins on startup.25if dein#check_install()26  call dein#install()27endifプラグインを追加する場合は、14〜15行目にあるcall dein#addに追加したいプラグインを指定していく。
プラグインはtoml形式の別ファイルに記述することも可能。
あとは、vimを起動することで自動的にdeinがインストールされる。
プラグインを別ファイル~/.vim/dein/dein.tomlで管理するようにする。
1# [[dein.toml]]23[[plugins]]4repo = 'Shougo/dein.vim'56[[plugins]]7repo = 'vim-airline/vim-airline'89[[plugins]]10repo = 'vim-airline/vim-airline-themes'1112[[plugins]]13repo = 'preservim/nerdtree'1415[[plugins]]16repo = 'tpope/vim-fugitive'~/.vimrcのdein.vimの部分を修正。
1"2"  dein.vim3"4if &compatible5  set nocompatible               " Be iMproved6endif78set runtimepath+=~/.vim/dein/repos/github.com/Shougo/dein.vim910if dein#load_state('~/.vim/dein')11  call dein#begin('~/.vim/dein')1213  let s:toml = '~/.vim/dein/dein.toml'14  call dein#load_toml(s:toml, {'lazy':0})15  16  call dein#end()17  call dein#save_state()18endif1920filetype plugin indent on21syntax enable2223" If you want to install not installed plugins on startup.24if dein#check_install()25  call dein#install()26endif