If Vim command-line is being edited and the Vim instance receives a string due to vim --remote-send KEYS executed on a shell somewhere, result is somewhat equivalent to pressing Return in the command-line and typing the received KEYS afterwards. Since the command that is unintentially executed can be hard to recover (an artificial example could be !rm -rf *), is there a way to prevent this behavior?Initial idea was to send e.g. <Esc><Esc>KEYS to discard any possible active input in the receiving Vim instance. This does quit a potentially active Insert mode and prevents KEYS landing in the current buffer. But this is does not work for the command-line input.I was thinking of some autocommand-event to trigger user confirmation upon remote keys receipt, but none of available events looked right for the case.
Discard command-line contents when receiving remote keys
command line;autocmd;clientserver
One solution (not perfect) is to use Ctrl-C instead, for example:vim --remote-send '<c-c>:echo test<cr>'This seems to work in command-line, normal, insert and visual mode, but not in operator-pending mode (at least in my test, after pressing va from normal mode with no timeouts).