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

134 views
Skip to first unread message

Peng Yu

unread,
Jun 30, 2012, 5:12:46 PM6/30/12
to vim_use
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

Ben Fritz

unread,
Jun 30, 2012, 11:21:08 PM6/30/12
to vim...@googlegroups.com
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.

Tony Mechelynck

unread,
Jul 1, 2012, 12:06:47 AM7/1/12
to vim...@googlegroups.com, Ben Fritz, vpeng...@gmail.com
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

Reply all
Reply to author
Forward
0 new messages