LoginSignup
65
63

More than 5 years have passed since last update.

Vim から Kobito.app を便利に使う

Posted at

Kobitoと外部ファイルとの連携ができるようになったので,早速 Vim から便利に使えそうな vimrc の設定を書いてみました.

function! s:open_kobito(...)
    if a:0 == 0
        call system('open -a Kobito '.expand('%:p'))
    else
        call system('open -a Kobito '.join(a:000, ' '))
    endif
endfunction

" 引数のファイル(複数指定可)を Kobitoで開く
" (引数無しのときはカレントバッファを開く
command! -nargs=* Kobito call s:open_kobito(<f-args>)
" Kobito を閉じる
command! -nargs=0 KobitoClose call system("osascript -e 'tell application \"Kobito\" to quit'")
" Kobito にフォーカスを移す
command! -nargs=0 KobitoFocus call system("osascript -e 'tell application \"Kobito\" to activate'")

:Kobito とすると編集中の markdown ファイルを Kobito.app で開くことが出来ます.また,:KobitoClose とすると直接 Kobito.app を閉じることが出来,:KobitoFocus でいつでも Kobito.app にウィンドウフォーカスを移すことが出来ます.
これらのコマンドをよく使う人はキーマップを設定しても良いかもしれません.
Vim 側で行った変更は保存時に自動的に Kobito.app にも反映されるので,markdown プレビューとしてなかなか便利に使えそうです.
Enjoy Kobito.app!!

スクリーンショット

screenshot

65
63
1

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
65
63