LoginSignup
1
0

More than 3 years have passed since last update.

初めてvimにプラグインを入れてみた

Posted at

駆け出しエンジニア兼プロゲーマーのガリレオです。
ゴリラ先生を習いvimを使い始めて7ヶ月が経ちましたが、自分でvimのプラグインを入れたことが無かったので入れてみました。

内容としてほぼ(というか全部?)ゴリラ先生の記事と一緒になってしまいましたが・・・

プラグインを入れるのは思ったより簡単だったのでどんどんカスタマイズしていきたい。

参考記事

導入方法

vim ~/.vimrc

" dein.vim settings {{{
" install dir {{{
let s:dein_dir = expand('~/.cache/dein')
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
" }}}

" dein installation check {{{
if &runtimepath !~# '/dein.vim'
  if !isdirectory(s:dein_repo_dir)
    execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir
  endif
  execute 'set runtimepath^=' . s:dein_repo_dir
endif
" }}}

" begin settings {{{
if dein#load_state(s:dein_dir)
  call dein#begin(s:dein_dir)

  " .toml file
  let s:rc_dir = expand('~/.vim')
  if !isdirectory(s:rc_dir)
    call mkdir(s:rc_dir, 'p')
  endif
  let s:toml = s:rc_dir . '/dein.toml'

  " read toml and cache
  call dein#load_toml(s:toml, {'lazy': 0})

  " end settings
  call dein#end()
  call dein#save_state()
endif
" }}}

" plugin installation check {{{
if dein#check_install()
  call dein#install()
endif
" }}}

" plugin remove check {{{
let s:removed_plugins = dein#check_clean()
if len(s:removed_plugins) > 0
  call map(s:removed_plugins, "delete(v:val, 'rf')")
  call dein#recache_runtimepath()
endif
" }}}

  • プラグインの追加

今回はキャメルケースとスネークケースを変換するプラグインを導入します。
今まで手動でやっていたけど量が多いと面倒なのでプラグイン導入を決意。

vim ~/.vim/dein.toml

[[plugins]]
repo = 'tyru/operator-camelize.vim'

[[plugins]]
repo = 'kana/vim-operator-user'
  • プラグインの設定

vim ~/.vimrc

vmap <leader>c <plug>(operator-camelize)
vmap <leader>C <plug>(operator-decamelize)
  • vimの再起動
    :source ~/.vimrc

  • 動作確認

  1. ビジュアルモードで選択
  2. スペース+Cでスネークケースに変換
  3. スペース+cでキャメルケースに変換

output.gif

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0