1

I want to autorun formatter when saving a file. Using BufWritePre doesn't work when quitting with :x (or ZZ), if the file hasn't yet been modified. ExitPre or QuitPre don't work either.

Kljunas2
  • 56
  • 1
  • 6
  • I do not think there is any autocmd for your special use case. Why do not just use `:wq`? – jdhao Nov 05 '21 at 05:19

1 Answers1

2

It's beacuse :x nor ZZ saves buffer when it's not modified. From documentation:

:x          Like ":wq", but write only when changes have been
            made.

If you would like to have it working on :x/ZZ you can map it to :wq which always saves buffer or use BufWinLeave

kosciej16
  • 6,294
  • 1
  • 18
  • 29