Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make BufWritePre work with :wa?

Tags:

vim

I have a BufWritePre hook, which unfortunately doesn't work with :wa, only with :w (and also with :wq).

How can I make it work with :wa as well?

This is a hook I have in my .vimrc: autocmd BufWritePre *.c* :ClangFormat

like image 376
syntagma Avatar asked Oct 28 '25 01:10

syntagma


1 Answers

BufWritePre are run only when the buffers are actually written. :w forces write, while :wall doesn't, it only writes those buffers that are modified. If you want to force writing all buffers (modified or not) you can do something like :bufdo w. This will also run BufWritePre and friends.

like image 185
lcd047 Avatar answered Oct 31 '25 02:10

lcd047



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!