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.
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.
:updatebasically is execute:writeif buffer is modified, else do nothing. The sameBufWritePre/BufWriteevents 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:writewould require re-writing the:updatecommand itself. For interactive use, that could be done via the cmdalias.vim plugin, which allows redefinition of lowercase built-in commands.