There doesn't seem to be a good way around what you're looking for.
The behavior is clearly documented, in quite some detail, in :help press-enter
.
In particular:
Press :
or any other Normal mode command character to start that command.
In your case, since you hit that from a CTRL-O
means the next keypress will actually be inserted in your text.
Note that not all keys will be recognized this way. For example:
Press k
, <Up>
, u
, b
or g
to scroll back in the messages. This works the same way as at the more-prompt. (Only works when 'compatible'
is off and 'more'
is on.)
These keys won't leave the "Press ENTER" prompt even if your command has no output (as is the case with :!true
.) If your command has long output, then once you scroll up, keys to scroll down will also be active and not leave the prompt to get inserted in your text.
There doesn't seem to be a way around it. I can see why you'd want a behavior such as "Press ANY key to continue" but that doesn't seem to be available.
You could file a new issue at the Vim tracker to request a way to tweak this behavior. (If you explain your use case invoking a command from CTRL-O
and having characters inserted into the text while the text is not visible, you might make such a feature request more compelling.) Though even if you successfully get that accepted, it will only be available in a future version of Vim, so not in generally available versions if you want to be compatible.
Most workarounds on this "Press ENTER" prompt are about hiding or preventing it (which you can easily do by adding an extra <cr>
to the end of your mapping.) But that doesn't seem to be what you want, since you do want the output of the command to be visible until the user presses Enter (or another key!)
Consider alternative solutions, such as saving the external command's output into a scratch buffer or preview window and displaying it there, you can better control the user experience that way.
:term