14
14

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 5 years have passed since last update.

Vimからmilkodeのgmilkコマンドを使う(Unite版)

Last updated at Posted at 2012-08-16

上記の記事の続き。

Uniteプラグインと、以下のUnite source をインストールすれば、以下のソースコードで、gmilk コマンドの実行結果を Unite インターフェースで表示してくれます。

必要なプラグインのインストール

(neobundle.vim のインストール方法は省略します)

.vimrc
NeoBundle 'Shougo/unite.vim'
NeoBundle 'sgur/unite-qf'
:NeoBundleInstall

ソースコード

.vimrc にでも記述してください。

" gmilk コマンドの結果をUnite qf で表示する
command! -nargs=1 Gmilk call s:Gmilk("gmilk -a -n 200", <f-args>)

function! s:Gmilk(cmd, arg)
  silent execute "cgetexpr system(\"" . a:cmd . " ". a:arg . "\")"
  if len(getqflist()) == 0
	echohl WarningMsg
	echomsg "No match found."
	echohl None
  else
	execute "Unite -auto-preview qf"
	redraw!
  endif
endfunction

実行例

:Gmilk [検索語句]

実行結果

このようにUniteインターフェースで表示されます

pキーで該当ソースのプレビューができるのですごく便利!

追記

-auto-preview オプションを追加したので、 pキーを押す必要なくなりました。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?