Friday, April 6, 2012

Re: "Press ENTER or type command to continue" behavior is different between gvim and terminal vim

On 22/03/12 5:37 PM, H Xu wrote:
> Hello,
>
> For the following vim script in a tmp.vim file:
>
> :!echo 1
> :!echo 2
>
> When executing ":so tmp.vim" in a terminal vim (I'm on Konsole of KDE), the output
> is like this:
>
> 1
>
> Press ENTER or type command to continue
> 2
>
> Press ENTER or type command to continue
>
> But on gvim:
>
> :!echo 1
> 1
> :!echo 2
> 2
>
> Press ENTER or type command to continue
>
> Note that on terminal vim, there are two "Press ENTER or type command to
> continue", but on gvim there is only one.

I think this is because in terminal Vim, Vim doesn't know what's
happening during the commands, so it assumes each command has filled the
screen and stops for you after each one so you can at least see the tail
output of each. But in GVim, the output goes through GVim itself, so it
knows when the screen is full; it can display the more prompt as well as
the press enter prompt exactly as many times as needed to ensure you see
all the output.

> Is there any solution to unify the behavior? I'm writing a vim script
> and this difference could be annoying.

Do you need to see the output? If not, maybe :silent would help? It will
suppress the prompt altogether. (In my terminal Vim the screen is messed
up after doing this, though, and I need to issue :redraw to fix it up.)

If you do need the output, maybe you need to use a function that
captures the output or redirect it to a temporary file and read that,
and then display it the way you want it, rather than just using :! which
is simpler but not as flexible.

Ben.

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