LoginSignup
2
1

More than 5 years have passed since last update.

ctrlp.vimでjvgrepを使う

Last updated at Posted at 2017-01-14

grepツールであるjvgrepが良い感じだったので、ctrlp.vimでも使うことにしました。

追記(2017-01-15)

Windowsで動かない場合以下のようにすると、動作すると思います。

let g:ctrlp_user_command = 'cd %s && jvgrep "" -i -r --no-color -l ./**/*'

Windowsで以下のように、%sを調べてみたところ"C:\dev"のようにダブルクォートで囲われて出力され、jvgrepのpath指定に渡すのが難しかったため、一旦cdで移動するという手法を取りました。

let g:ctrlp_user_command = 'echo %s'
" => "C:\dev"

ctrlp.vimでjvgrep

ctrlp.vimのg:ctrlp_user_commandに以下のように設定すると動きました(optionは好みで変更して下さい)。

if executable('jvgrep')
  let g:ctrlp_use_caching = 0
  let g:ctrlp_user_command = 'jvgrep "" -i -r --no-color -l %s'
endif

ag等を使用する場合、以下のように%s""(ダブルクォート)より左に配置される例がよく見られますが、jvgrepでは右に配置しないと動きませんでした。

let g:ctrlp_user_command = 'ag %s -i --nocolor --nogroup -g ""'

そもそもctrlp.vimのhelpに

Use %s in place of the target directory

とあるので、右側に配置する方が(個人的には)自然だと思います。

2
1
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
2
1