Saturday, June 30, 2012

Re: How to just load a vim file and run the command and print the output to stdout and exit?

On 01/07/12 05:21, Ben Fritz wrote:
> On Saturday, June 30, 2012 4:12:46 PM UTC-5, Peng Yu wrote:
>> Hi,
>>
>> I just want to run some vim script and print output to stdout and
>> exit. The following will print something at the bottom of the screen
>> without exiting vim. Is there a way to do want I want? Thanks!
>>
>> vim -c "source main.vim"
>>
>> Regards,
>> Peng
>
> You can make Vim quit after running the script like this:
>
> vim -c "source main.vim" -c "q"
>
> Or even better:
>
> vim -S main.vim -c "q"
>
> But I don't know of any way to make Vim print arbitrary stuff to stdout.
>

When started with the -es switches in that order (see :help -s-ex), some
messages will be printed on stdout, but only from a _very limited_ set
of commands. The normal Vim display is suppressed in that mode.

If you're a really lazy typist, like I am, you could even use (maybe
somewhat baroquely)

vim -es -S main.vim -cq

(the space is optional after -c in that case, maybe for compatibility);
or if your script is named Session.vim in the current directory, and
includes the final :q line,

vim -esS

would (I think) be enough.


Best regards,
Tony.
--
"There is a God, but He drinks"
-- Blore

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

No comments:

Post a Comment