Vim Tips Wiki

Tip 443 Printable Monobook Previous Next

created 2003 · complexity basic · author Christian Obrecht · version 6.0

Vim's quickfix mode is a very nice feature. Nevertheless, I was not completely satisfied when I used it together with (La)TeX. Here are the main reasons:

  • The default error format pattern is able to extract the line number and the error message, but not the column number.
  • This pattern is of course unable to deal with BibTeX's or MakeIndex's error messages.
  • TeX's messages are quite verbose. Having them displayed at each run, even when no error occurs is sometimes annoying.

Thus I implemented TeXwrapper, a small program which silently runs TeX and optionally some associated tool like BibTeX, MakeIndex, eukleides or Dvips. When an error occurs, TeXwrapper scans the transcript files and prints to stderr "compiler style" error messages, i.e.:


This allows very simple settings on Vim's side, that is:

set makeprg=texwrapper
set errorformat=%f:%l:%c:%m

Someone writing an article with LaTeX containing cross references and a bibliography may then use: "make -lb2 %". Option -l stands for "run LaTeX" (instead of TeX), -b for "run BibTeX", -2 for "run twice" (to get correct cross references).

Another feature is the --window option (short: -w). When something goes wrong, a GTK+ window pops up, displaying a summary of the encountered errors. Hence, one may use: "silent make -w %" which enables to avoid the "Hit ENTER or type command to continue" message at each run.

TeXwrapper has been developed on a GNU/Linux system, but it should build on any system where flex has been ported. The pop up window is opened by a separate program, named texwrapper_window, which of course requires the GTK+ library.

TeXwrapper has been released under the GPL and is available at:


Recent versions of and LaTeX now come with a -file-line-error switch, which let's it output file:line:error style messages. I use the following settings to work with pdflatex:

let b:tex_flavor = 'pdflatex'
:compiler tex
:set makeprg=pdflatex\ \-file\-line\-error\ \-interaction=nonstopmode
:set errorformat=%f:%l:\ %m

Some mappings may also be helpful

map <F7> :w<CR>:make %<<CR>
map <F8> :!xpdf %<.pdf &<CR>
map <F9> :cprev<CR>
map <F10> :cnext<CR>
map <F11> :clist<CR>

If you don't like seeing all the unnecessary lines (which are picked up by quickfix, if there are no errors), you can use grep for filtering:

:set makeprg=pdflatex\ \-file\-line\-error\ \-interaction=nonstopmode\ $*\\\|\ grep\ \-P\ ':\\d{1,5}:\ '

Regarding the last makeprg option: why doesn't

:set makeprg=pdflatex\ \-file\-line\-error\ \-interaction=nonstopmode\ % \|\ grep\ \-P\ ':\\d{1,5}:\ '

work? (It's not necessary in the setup above, but bugs me anyway)