I'm developing a Vim plugin That needs to run a shell command(targeted for running compilers and build systems) and capture it's output. I also want to display the command's stdout and stderr as it runs, so I'm using Ruby for running the command(though I'm still displaying with Vim's :echo command, so I can set the highlight for stderr)
Anyways, I want to allow the user to cancel the command in the middle. Canceling a program is traditionally done with Ctrl+C, and Vim's allows the user to use Ctrl+C to cancel the current running vimscript by throwing Vim:Interrupt. I want to use Vim's :sleep command to allow the user to press Ctrl+C if they want to cancel the command they are running, catch Vim:Interrupt, and proceed accordingly.
My problem is that pressing Ctrl+C in Vim while not in insert mode causes Vim to display Type :quit<Enter> to exit Vim - and to erase whatever messages were echoed before. This is a problem for me, because I want to keep whatever output the command put in stdout and stderr before the user canceled it displayed(and maybe add a message that the command was canceled).
Is there any way to temporarily disable this message and keep whatever was echoed before the user pressed Ctrl+C?
You can prepend the left hand side of your mappings with <silent> to hide what they would normally output on the command line.
In this case, the following mapping should work (it seems to, here):
nnoremap <C-c> <silent> <C-c>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With