Buffer autosave: do in vim?

Is there a way to autosave the buffer before release: make? I use MacVim and make is bound to Command-B, which is very useful, but I cannot figure out how to write a buffer before make. I looked at all the events of autocmd and nothing seemed to fit.

There QuickFixCmdPre, which must be called before make, but cannot make it work:

~ / .vimrc

function! AutoSaveOnMake () if &modified write endif endfunction autocmd QuickFixCmdPre *.c :call AutoSaveOnMake() 
+7
source share
2 answers

Vim has a built-in setting for this:

 :set autowrite 

Write down the contents of the file, if it has been changed, on each: next ,: rewind ,: last ,: first ,: previous ,: stop ,: suspend ,: tag,:!,: Make, CTRL-] and CTRL- ^; and when a: buffer, CTRL-O, CTRL-I, '{A-Z0-9} or `{A-Z0-9} receives one from another file.

+18
source

Instead of creating an autocmd , why not just update the Command-B mapping?

 nnoremap <db> :update<bar>make<cr> 
+3
source

All Articles