I have a vim script that I am sourcing with --cmd "source path/to/file.vim"
. The full command is a bit longer and the final command is to quit vim like so.
vim --cmd 'source path/to/file1.vim' [... source other files] --cmd ':q'
In these files I am doing some processing that outputs messages to vim with echomsg
. I want to capture these messages to stdout
.
The problem is some of this processing requires sleeping for a bit with sleep
. However doing a sleep
causes vim to redraw the screen. As a result messages that were echoed initially are partially cleared in this screen redraw.
Once I quit Vim I can see that the messages were output in sequence correctly in the shell, but the intermittent redrawing messed up the display.
One workaround I came up with is to use writefile
to write the messages to a file instead of using stdout, but then I loose the ability to show progress.
Is there a better way to capture echo'ed messages to stdout from a vimscript? I would like to display the messages as they occur, as these are progress messages.
Thanks.