Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like that vim automatically compiles a lout document (similar to LaTeX) every time I save the document.

Is there a possibility to add such functionality to save? (Preferably without using anything else than :w to save.)

share|improve this question
up vote 11 down vote accepted

You can do that with an autocommand. I don't have one that loads automatically, but if I know I'm going to be going through the edit-compile-edit cycle for a while with one file, I'll execute something like this at the Vim command line:

:au BufWritePost * make

You can replace make with whatever build or run command is appropriate.

share|improve this answer

@garyjohn 's answer is correct.

and let me add an example on how to run multiple compile on coffeescript:

# add these lines to your .vimrc file (~/.vimrc in my pc)
autocmd BufWritePost,FileWritePost *.coffee :silent !coffee --compile --join appstore/static/javascripts/angular/controllers.js

autocmd BufWritePost,FileWritePost *.coffee :silent !coffee --compile appstore/static/javascripts/angular/ appstore/static/javascripts/angular/ appstore/static/javascripts/angular/ appstore/static/javascripts/angular/
share|improve this answer

Your Answer


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.