LoginSignup
11
10

More than 5 years have passed since last update.

vimでファイルを開かずexコマンド実行だけ行う方法

Last updated at Posted at 2014-10-16

タイトルの通りです。調べても分かんね、という声を耳にしたので共有メモ

例えばプラグインの管理にneobundleを使っていて、プラグインの一括更新を:NeoBundleInstall!で行いたい(けどいちいちファイルは開きたくない)って場合はこんな感じ

  • exコマンドを羅列したファイルを用意する。このとき最終行はq(もしくはq!)にしてvimが終了するようにしておく
$ vim excmd.txt

NeoBundleInstall!
q!
  • vimを-e -Sオプション付きで実行する。この時に-Sの引数として先ほどのexコマンド羅列ファイルを指定する
% vim -e -S excmd.txt
 : (ズラズラと更新ログが表示される)

%
  • -e-Sオプションについて
       -e          Start Vim in Ex mode, just like the executable  was  called
                   "ex".

       -S {file}   {file}  will be sourced after the first file has been read.
                   This is equivalent to -c "source  {file}".   {file}  cannot
                   start with '-'.  If {file} is omitted "Session.vim" is used
                   (only works when -S is the last argument).
11
10
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
11
10