Automate LaTeX compilation in vim with LaTeX-Suite

For editing LaTeX-documents I use exclusively vim with the great LaTeX-Suite. Usually I have an automatically refreshing pdf-viewer like evince next to my editor, and compile manually with pdflatex from another terminal, so after each compilation my changes appear in the pdf-viewer. Since I'm using a tiled window manager, this was reasonably comfortable, but I still had to recompile the document manually every time I saved some changed. However, today I added two lines to my .vimrc, which automate this process and make vim automatically compile the .tex-file every time it's saved:

let g:Tex_DefaultTargetFormat='pdf'
au BufWritePost *.tex silent call Tex_CompileLatex()

The first line lets vim know, that I want it compiled to pdf; if you use other output formats you might want to change this, or leave this line out if your target format is dvi. The second line is where the magic happens, however it suppresses any error messages produced by the compiler. But this shouldn't be a problem in most cases and one can easily fall back to manual compilation if matters get more complicated.

blogroll

social