Vim プラグインを pathogen で管理してきたけど…
今では後発の Vundle の方が主流ぽいので、pathogen から Vundle に移行することにしました。Vundle は Ruby の Bundle をインスパイアしていて、GitHub や vimscripts からプラグインファイルをダウンロードしてインストールできるという。なにそのステキ機能。スバラシイ。
私のマシンは Windows なので、Windows で Vundle を導入した手順を書いていきます。
まずは下準備
Vundle が GitHub や vimscripts からプラグインをダウンロードするには、git と curl コマンドが必要。まず git を msysgit でインストール。
そして、下記の内容を記述した curl.cmd ファイルを、C:\Program Files\Git\cmd ディレクトリに作成。
@rem Do not use "echo off" to not affect any child calls.
@setlocal
@rem Get the abolute path to the parent directory, which is assumed to be the
@rem Git installation root.
@for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI
@set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%PATH%
@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%
@curl.exe %*下記のコマンドが通れば OK。
git --version curl --version
Vundle をインストール
Vundle のインストールは git で行う。ユーザーのホームディレクトリで次のコマンドを実行。
git submodule add http://github.com/gmarik/vundle.git %USERPROFILE%/dotfiles/.vim/bundle/vundle
dotfiles ディレクトリは .vimrc や .zshrc を管理しているディレクトリ。pathogen を導入してから、.vimrc や Vim プラグインは Git でバージョン管理しています。
Vundle を有効化
Vundle を有効にするために .vimrc を編集。ついでに利用するプラグインも記述しておきます。
set nocompatible " be iMproved filetype off " required! if has('win32') || has('win64') let $DOTVIM = expand('~/vimfiles') else let $DOTVIM = expand('~/.vim') endif set rtp+=$DOTVIM/bundle/vundle/ call vundle#rc('$DOTVIM/bundle') " let Vundle manage Vundle " required! Bundle 'gmarik/vundle' " My Bundles here: " " original repos on github Bundle 'Shougo/neocomplcache' " vim-scripts repos Bundle 'project.tar.gz' filetype plugin indent on " required! syntax on set autoindent set expandtab set number set nobackup set backspace=indent,eol,start set tabstop=4 set softtabstop=4 set shiftwidth=4
Linux でも使えるように、.vim のパスを切り替えています。このやり方は下の記事を参考にしました。
Ubuntu で動くことは確認済みです。
dotfiles ディレクトリ内に .vimrc や .vim をまとめているけど、これらはユーザーのホームディレクトリに置く必要があるので、シンボリックリンクを作成します。Windows だと名前を変更する必要あるので、リンクの名前は .vim ではなく vimfiles、.vimrc ではなく _vimrc で作成しておきます。
mklink _vimrc dotfiles\.vimrc mklink /D vimfiles dotfiles\.vim
あとは
Vim を起動して、BundleInstall コマンドを実行すれば、プラグインがインストールされます。不要になったプラグインは .vimrc から消して BundleClean で 削除すれば OK。
最終的にこんな感じ
C:.
│ .gitignore
│ .gitmodules
│ .gvimrc
│ .vimrc
│
└─.vim
└─bundle
├─neocomplcache
│ │ .gitignore
│ │ README
│ │
│ ├─autoload
│ │ │ neocomplcache.vim
│ │ │ vital.vim
│ │ │
│ │ ├─neocomplcache
│ │ │ │ async_cache.vim
│ │ │ │ cache.vim
│ │ │ │ util.vim
│ │ │ │
│ │ │ └─sources
│ │ │ │ abbrev_complete.vim
│ │ │ │ buffer_complete.vim
│ │ │ │ completefunc_complete.vim
│ │ │ │ dictionary_complete.vim
│ │ │ │ filename_complete.vim
│ │ │ │ include_complete.vim
│ │ │ │ keyword_complete.vim
│ │ │ │ omni_complete.vim
│ │ │ │ snippets_complete.vim
│ │ │ │ syntax_complete.vim
│ │ │ │ tags_complete.vim
│ │ │ │ vim_complete.vim
│ │ │ │
│ │ │ ├─snippets_complete
│ │ │ │ actionscript.snip
│ │ │ │ apache.snip
│ │ │ │ applescript.snip
│ │ │ │ c.snip
│ │ │ │ coffee.snip
│ │ │ │ cpp.snip
│ │ │ │ css.snip
│ │ │ │ d.snip
│ │ │ │ eruby.snip
│ │ │ │ java.snip
│ │ │ │ javascript.snip
│ │ │ │ markdown.snip
│ │ │ │ objc.snip
│ │ │ │ perl.snip
│ │ │ │ php.snip
│ │ │ │ python.snip
│ │ │ │ rails.snip
│ │ │ │ ruby.snip
│ │ │ │ sh.snip
│ │ │ │ snippet.snip
│ │ │ │ tex.snip
│ │ │ │ vim.snip
│ │ │ │ vimshell.snip
│ │ │ │ xhtml.snip
│ │ │ │ _.snip
│ │ │ │
│ │ │ └─vim_complete
│ │ │ autocmds.dict
│ │ │ commands.dict
│ │ │ command_args.dict
│ │ │ command_completions.dict
│ │ │ command_prototypes.dict
│ │ │ command_replaces.dict
│ │ │ features.dict
│ │ │ functions.dict
│ │ │ helper.vim
│ │ │ mappings.dict
│ │ │ options.dict
│ │ │ variables.dict
│ │ │
│ │ ├─unite
│ │ │ └─sources
│ │ │ file_include.vim
│ │ │ neocomplcache.vim
│ │ │ snippet.vim
│ │ │
│ │ └─vital
│ │ │ neocomplcache.vital
│ │ │ _bc73c2.vim
│ │ │
│ │ └─_bc73c2
│ │ │ functor.vim
│ │ │ prelude.vim
│ │ │
│ │ ├─data
│ │ │ list.vim
│ │ │ ordered_set.vim
│ │ │ string.vim
│ │ │
│ │ └─system
│ │ file.vim
│ │ filepath.vim
│ │
│ ├─doc
│ │ neocomplcache.jax
│ │ neocomplcache.txt
│ │
│ ├─ftplugin
│ │ snippet.vim
│ │
│ ├─indent
│ │ snippet.vim
│ │
│ ├─plugin
│ │ neocomplcache.vim
│ │
│ └─syntax
│ snippet.vim
│
├─project.tar.gz
│ │ README
│ │
│ ├─doc
│ │ project.txt
│ │
│ └─plugin
│ project.vim
│
└─vundle
│ README.md
│
├─autoload
│ │ vundle.vim
│ │
│ └─vundle
│ config.vim
│ installer.vim
│ scripts.vim
│
├─doc
│ tags
│ vundle.txt
│
└─test
minirc.vim
vimrc余談だけど、プラグインのバージョン管理をする必要ないので、bundle 以下は .gitignore で除外しておきました。おかげで Git リポジトリがスッキリ。