Is there any way to autosave the buffer before issuing :make? I use MacVim and make is bound to Command-B, which is very helpful but I cannot seem to figure out how to write the buffer before a make. I looked at all the autocmd events and nothing seemed to fit.
There's a QuickFixCmdPre which should be called before a make but can't seem to get it to work:
~/.vimrc
function! AutoSaveOnMake ()
if &modified
write
endif
endfunction
autocmd QuickFixCmdPre *.c :call AutoSaveOnMake()
Vim has a built-in setting for that:
:set autowrite
Write the contents of the file, if it has been modified, on each :next, :rewind, :last, :first, :previous, :stop, :suspend, :tag, :!, :make, CTRL-] and CTRL-^ command; and when a :buffer, CTRL-O, CTRL-I, '{A-Z0-9}, or `{A-Z0-9} command takes one to another file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With