LoginSignup
4
4

More than 5 years have passed since last update.

unite.vimで検索辞書を設定して検索単語入力を減らす

Last updated at Posted at 2014-06-29

unite.vimはunite#custom#substituteで検索用の置換辞書を設定することができます。設定次第でunite.vimによる絞り込み検索が楽になるんじゃないかと思って設定してみました。

引数は以下のようになります

" 指定したprofile_nameでkeywordを入力した時にpatternで置換する。
call unite#custom#substitute(profile_name, keyword, pattern, priority)

検索でkeywordを入力した時にpatternに置換されます。

たとえば私はrailsを使って開発しているので、以下の様な設定にしてunite-railsっぽくしてみます。

" 面倒なのでdefaultにしている priorityは省略
call unite#custom#substitute('default', '[[:blank:]]\zsm\ze[[:blank:]]\|^\zsm\ze[[:blank:]]', 'models')

この設定を入れると、unite.vimでの検索時にm<Space>と入力することで、検索キーワードにmodelsと入力したことと同じ意味になります。
ちょっと長いのでfunctionにしましょう。名前はテキトーです。

function! Unite_substitute(pattern, substitute)
  call unite#custom#substitute('default', '[[:blank:]]\zs' . a:pattern ze[[:blank:]]\|^\zs' . a:pattern . '\ze[[:blank:]]', a:substitute)
endfunction

最終的には以下のようにしました。

call Unite_substitute('m', 'models')
call Unite_substitute('v', 'views')
call Unite_substitute('c', 'controllers')

あとは好きなように検索辞書を充実させるとキータイプが減るかもしれません。

4
4
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
4
4