tags:

views:

68

answers:

3

I want to call an command when I save the file. I am calling it by :make manually now. but I wish it could be called when I execute :w and :wq

I also want enable this feature in any subfolders where not contains a Makefile but it's parents contains one. Just like this topic said, but it doesn't works for me.

http://stackoverflow.com/questions/729249/how-to-efficiently-make-with-vim

+1  A: 
:autocmd BufWritePost <buffer> make
too much php
the "make" is as a shell command or a vim command? could it be an vim function?
guilin 桂林
`:make` is a vim command that runs the `make` shell command and reads its output to make sure everything worked.
too much php
+2  A: 
au BufWritePost        *.c
            \ make
amphetamachine
It's worth pointing out that this goes in ~/.vimrc.
Pablo Alejandro Costesich
@Pablo - Actually, it goes in `~/.vim/filetype.vim`.
amphetamachine
A: 

Put something like this in your .vimrc :

:map :w :make<ENTER>:w
:map :wq :make<ENTER>:wq

Then whenever you type :w, it will do a :make first.

thedayturns
Those mappings are recursive, and they would also run make **before** saving the file.
too much php