Vimにneosnippet.vimを導入してみたので使い方をメモ。
neosnippetの導入
neosnippetのインストールはneobundleで行った。
NeoBundle 'Shougo/neosnippet'
neosnippetを使うには以下のコードを.vimrcに記述する。(Kaoriya版Vimの場合は_vimrcに記述)
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"
if has('conceal')
set conceallevel=2 concealcursor=i
endif
このコードは本家にあるneosnippetの設定コードなので、とりあえず真似して記述する。
neosnippet-snippetsを導入する
neosnippetはスニペットの定義ファイルが無いと動作しないので、定義ファイルを集めたneosnippet-snippetsを導入する。
こちらもneobundleでインストールする。
NeoBundle 'Shougo/neosnippet-snippets'
neosnippetの使い方
今回はPHPファイルで使用感を確認した。test.phpを適当な場所に作成し、Vimで開く。おもむろにforと打ち込むとfor文やforeach文などの入力補完の候補が画面に現れる。
順方向に補完候補を選択するには<C-n>とする。逆方向に補完候補を選択するには<C-p>とする。
補完候補から入力を決定するにはTabを押す。<Tab>を押すごとにマーカーごとにジャンプができる。