0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

対話的にファジー検索

Last updated at Posted at 2022-11-20

fzfに劣る

劣るが、findコマンドだけで動くので、別途なにかコマンドなどを入れる必要がない。
この程度ならその場でさくっと作れるので、覚えておくと損はないと思う。

関連
100行でfzf

仕組み

inputdialogを使用する

①キーワードを入力させ
②find結果を表示し、選択させる

と2段階の対話になるので、普通に関数を用意するだけでは足りない。

.vim
" fzf like
fu! FzfPatternExe() abort
  echo execute('pwd')
  let inarr = split(inputdialog("Enter [ext] [pattern]>>"), ' ')
  if len(inarr) !=  2
    echo 'break'
    retu
  endif
  let fzf_cmd = 'find ./* -iname "*' . inarr[1] . '*.' . inarr[0] . '"'
  echo 'searching ... [ ' . fzf_cmd . ' ]'
  let fzf_res = split(system(fzf_cmd), '\n')
  echo '_________________________'
  for v in fzf_res
    echo index(fzf_res, v) . ': ' . v
  endfor
  echo '_________________________'
  let ope = len(fzf_res) == 0 ? '' : inputdialog("choose >>")
  exe ope == '' ? 'echo "break"' : 'e' . fzf_res[ope]
endf

結果

地味に便利だが、fzfがあるならそれでいい。ない時に仕方なく使える技術

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?