How to run Vim command from the shell?
From the vim(1)
man page:
+{command}
-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.
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.
While the vim specific recipe above is the right way to do it, you can always use a more general approach like autoexpect.