Vim: Showing an error message from a Vim Script

knipknap picture knipknap · Feb 22, 2010 · Viewed 12.1k times · Source

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.

Answer

Randy Morris picture Randy Morris · Feb 22, 2010

I think you are looking for echoerr.