UPDATE: Another interesting option is to use rubber, a Python-based LaTeX wrapper. Among lots of other things, it sanitizes both error and warning messages in a format that's easy to use by Vim.
UPDATE: Most recent implementations of LaTeX can be told to generate sanitized error (but not warning!!) messages automatically. See
Additionally, Martin Sander has put together a Python version of the vimlatex script.
- a description of how to modify Vim-LaTeX to use this feature
- a more general fix for Vim and LaTeX (in "Comments" section of the link)
NOTE: Personally, I use vimlatex and I do not instruct LaTeX to sanitize its error messages internally.
If you use Vim-LaTeX, you've probably noticed that sometimes errors will cause Vim to open up a completely unrelated file on top of your current file. This is Vim's way of bringing you to the source of the error, but it parsed the latex return text improperly.
The problem is that LaTeX status messages keep track of which file is being used with parentheses over multiple lines. So, in order to figure out where an error is, Vim has to match opening parentheses with closing parentheses over multiple lines. Unfortunately, Vim's compiler error message features cannot do this if multiple parentheses are on one line.
So, I shamelessly borrowed an solution from Luc Hermitte's VIM Macros. Specifically, I was inspired by the vim-tex.sh, which pipes TeX output through a filter that corrects any problems that could confuse Vim. However, I didn't like that his script needed to create a temporary file, so I then borrowed a shell script tip off of a UNIX forum that copies file descriptors around so that actual disk files aren't needed.
The result is vimlatex, a shell script that post-processes TeX output so that it's in a form that Vim likes. To use it, just put it in your PATH and make it executable (i.e., chmod it 0755) and then add vimlatex in front of any compiler command you have. For example, if you have a compiler line in your .vimrc or in your Makefile that starts with latex, insert vimlatex (and a space) in front of the latex (i.e., change latex to vimlatex latex).
Alternatively, any output piped to vimlatexpipe will get properly sanitized for Vim too.