Wednesday, July 28, 2010

How to run vim commands for certain file types

For the longest time I've created .tex files in vim and typeset them with pdflatex.  The problem is that every time I need to type

:set makeprg=pdflatex\ %

This was frustrating because I use tex all the time.  Alas, the solution is to place the following in your ~/.vimrc:

autocmd FileType tex setlocal makeprg=pdflatex\ %