In vim, I use external code formatters to beautify my code. Vim supports that. One can set the "formatprg" option to an external program that formats code. See :help formatprg. The formatprg takes your unformatted code on the stdin and puts the formatted code to the stdout.
Now, when the formatprg succeeds, everything works very well. But when something goes wrong, an error message is put to stderr. Unfortunately, vim doesn’t recognize this, and your unformatted code is replaced with the error message.
How can I redirect errors to vim's echoerr?
Thanks in advance.
You can avoid that the error output is inserted into the buffer by
:set shellredir=>%s
but still, the text will be cleared, with litte indication that an error has occurred. You can easily :undo the bad modification (u), though.
This similar question shows a workaround, but to me this looks ugly, and I wonder why Vim does not evaluate the external program's exit code. (I'll go ask on vim_dev for the reasons behind this. Edit: Here it is)
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