On 2014-01-10, Benjamin Klein wrote:
> I know that I can right now do something like
> 
> :echo system(“external --command”)
> 
> and have Vim (after waiting for the command to finish) `echo` the output as a 
> message.
> 
> Is there a way for me to have each new line of output from the
> command `echo`ed as a message as it occurs? This command takes
> some time to run and rather than wait for it to finish before
> seeing any output I’d like to be able to follow what it’s doing as
> it goes.

The only way I know of to capture the output of a command for use by
Vim and also see each line as it is generated is to use tee.

One way is to use system() like this:

    :let output = system("external --command | tee /dev/tty")

The trouble with that is that the output to /dev/tty goes behind
Vim's back, so to speak, and messes up your display until you
refresh, e.g., with Ctrl-L.

Another, better way is used by Vim's :grep and :make commands, which
tee the output to a temporary file while letting stdout and stderr
go to the display.  For example:

    :!external --command | tee /tmp/tmpfile

Then you can read the temporary file using system() or readfile() or
by whatever means is appropriate for your task.

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to