I've just developed a nice solution for automatically loading external changes made to a file, but I'd like a more obvious notification when autoread changes my buffer.

Is there a way of having a warning text appear (eg coloured red) when autoread triggers, so I can easily notice any changes?

1 Answer 1


One way to create a highlighted message is this:

echohl WarningMsg | echo "Buffer changed!" | echohl None

The first command selects a particular highlight mode for any subsequent echo calls. When echo is called the message will be displayed on the status line with approriate color and/or format (in my case white on yellow text). Don't forget the second echohl to return to regular highlighting.

Now I believe you want to display this when autoread is triggered. I am having success with this autocommand:

autocmd FileChangedShellPost *
  \ echohl WarningMsg | echo "Buffer changed!" | echohl None

I do set autoread in my vimrc, load a file with gvim, load it with another editor and change something, come back to gvim. Voila, I get the highlighted message.

  • That text style is what I'm after... but it's an event, not a script... see the link added to autoread in the question.
    – Tom Hale
    Aug 1, 2017 at 4:15
  • You might be able to use event FileChangedShell. :h E321 implies that this event is associated with autoread.
    – B Layer
    Aug 1, 2017 at 4:39
  • 1
    Actually FileChangedShellPost is working for me. Updating my answer.
    – B Layer
    Aug 1, 2017 at 4:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.