I am trying to implement an AutoCmd
in Vim that needs to be executed when the current buffer has been modified.
I have read through all the events available for AutoCmd
in the docs but could not find something that would help determine when a buffer was modified or not.
This doesn't necessarily mean "when a buffer was written" because the action I need to trigger needs to be called when the buffer has been modified including being written.
Any ideas on how to implement a BufIsModified
that could achieve this objective?
Note: not a duplicate of What is a vimrc function to determine if a buffer has been modified?, since this question is about an autocmd
and not only the buffer modified check
The only thing popped into my mind is to use the CursorMoved
and CursorMovedI
events.
HTH
来源:https://stackoverflow.com/questions/5606914/vim-buffer-has-been-modified