Autocompiling CoffeeScript on Save in VIM

There are two problems with keeping a "daemon" compiling CoffeeScript and those are error handling and always having to initialize that daemon. However, there is a simpler way.

Changing .vimrc

Keeping some kind of long running process just to compile CoffeeScript running doesn't really seem like the right solution. Since VIM has great support for modding and making your custom scripts and commands in .vimrc, I decided to find a solution for autocompiling on save instead:

autocmd BufWritePost,FileWritePost *.coffee :silent !coffee -c <afile>

Pretty simple, right? Add parameters according to the CoffeeScript documentation to customize the compilation. For example, I don't want to wrap all my separate files with CoffeeScript own wrapper, so I'll add --no-wrap:

autocmd BufWritePost,FileWritePost *.coffee :silent !coffee --no-wrap -c <afile>

Tada! The simple way to compile CoffeeScript on save in VIM!