Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This might be a dumb question, but bear with me.

I'm automating some of the usual stuff I do when setting up a new work environment, and would like to automate the Vim command :BundleInstall (for installing all my Vim plugins).

Is it possible to run this from the shell?

Alternatively, is it possible to have the script run Vim, execute :BundleInstall, wait until it finishes and quit?


share|improve this question
up vote 12 down vote accepted

From the vim(1) man page:


-c {command}

{command} will be executed after the first file has been read. {command} is interpreted as an Ex command. If the {command} contains spaces it must be enclosed in double quotes (this depends on the shell that is used). Example: Vim "+set si" main.c

Note: You can use up to 10 "+" or "-c" commands.

share|improve this answer
Thanks! I knew I'd feel dumb... :-/ Serves me right for not reading the manpage thoroughly. I ended up using vim +BundleInstall +qall!. – imiric Jul 21 '12 at 23:18

While the vim specific recipe above is the right way to do it, you can always use a more general approach like autoexpect.

share|improve this answer

You can execute your command like this:

vim -E -c BundleInstall -c q

which will avoid opening a Vim window in your terminal.

Note: My first answer included the -s option which I had needed for another application but was incorrect here because it prevented much of Vim's intialization including sourcing the plugin that defined the BundleInstall command.

share|improve this answer
Thanks, but for some reason it won't work for me. – imiric Jul 21 '12 at 23:19
Now I see why. I forgot that -s does more than inhibit certain messages--it also inhibits intializations--so the definition of BundleInstall wasn't being sourced. One way to fix that would be to add an option like this before the first -c: --cmd 'runtime plugin/bundle.vim'. Edit that file name to suit. See :help -s-ex. – garyjohn Jul 24 '12 at 0:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .