On 2011-07-17, Keith Christian wrote:
> What would be the command format to run three commands from a shell
> command line (e.g. BASH) to run a VIM command, save the output, and
> quit?
>
> Below, I'd like to save the output of the "scriptnames" command in a
> file called "vim_output" and quit the editor with no further
> interaction, in order to examine the vim_output file later.
>
> This doesn't work:
>
> vim +"scriptnames" +":w vim_output" +":q"
>
> Is this possible without writing a VIM script? I don't see any way to
> issue three VIM commands from the command line. What is the command
> separator in this case, or is there one?
:help :|
> If I have to write a VIM script to do these three actions, is there a
> command line option to have VIM run a script to do these things, and
> then exit cleanly?
You were very close. One reason it didn't work was because the
:scriptnames command put Vim into interactive mode (my term) when it
issued the "-- More --" prompt and Vim stayed in that mode. The
other problem was that the :scriptnames command writes to the
screen, not to a Vim buffer, so there was nothing to write to your
file. Here is a version that works.
vim +"set nomore" +"redir > vim_output" +"scriptnames" +"q"
The "set nomore" stops that "-- More --" prompt. The "redir >
vim_output" sends the output of the subsequent commands to the file
vim_output". The "q", of course, quits Vim. Note, though, that
none of those commands start with ":". They could, but it's
unnecessary.
See also
:help -c
:help 'more'
:help :redir
Regards,
Gary
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php