This is because I'd like to automatically run tests after each file save.

I have looked at autocmd and BufWritePost but cannot make it work.

share|improve this question
up vote 47 down vote accepted

This runs run_tests.sh after any file is saved, with the current filename as the only parameter:

:autocmd BufWritePost * !run_tests.sh <afile>

View the auto-command with:

:autocmd BufWritePost *

And remove all auto-commands from the previous with:

:autocmd! BufWritePost *
share|improve this answer
    
Is there a way to to something like this ?: if a file named tests.html is present in the current directory OR in the directory just above then run command testprog tests.html OR cd .. testprog tests.html ? – Running Turtle Jan 10 '11 at 22:11
3  
@Running Turle: I would create a function for this and then use it in an autocmd. Use filereadable() to test if there is a file and then act accordingly. – blueyed Jun 3 '11 at 10:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.