I would like to do some code reformatting whenever :update
command is executed, is this possible?
I can't find any autocommand hook for updating, only for :w
command.
:update
basically is execute :write
if buffer is modified, else do nothing. The same BufWritePre
/ BufWrite
events apply to it (when the former case is true). That should be perfectly suitable for your reformatting trigger.
To only trigger on :update
, but not on :write
would require re-writing the :update
command itself. For interactive use, that could be done via the cmdalias.vim plugin, which allows redefinition of lowercase built-in commands.