47

I am trying to show an error message in a Vim script:

function! Foo()
    " ...
endfunction

au BufWritePost *.py silent call Foo()

The "throw" keyword works, but is probably not the right way to do this. I found references to "echomsg", but this doesn't have any effect:

echohl ErrorMsg
echomsg 'Hello World'
echohl NONE

I also tried to write into v:statusmsg (also no effect). Any idea?

In addition, I'd probably also want to stop the signal propagation like throw() does, i.e. such that other hooks that listen to the BufWritePost event are not called.

knipknap
  • 5,934
  • 7
  • 39
  • 43
  • Unfortunately there is __NO__ function to get error message from number. As you can see messages are hard coded (am I right ?) : https://github.com/vim/vim/blob/079119babe1cbba3f9234927e62fd75465f2d6b4/src/globals.h#L1515 – Tinmarino Dec 04 '19 at 00:17

1 Answers1

62

I think you are looking for echoerr.

Randy Morris
  • 39,631
  • 8
  • 69
  • 76