Take the 2-minute tour ×

I am using vim to edit latex files. The document is long and so I split each chapter in its own .tex file. Each .tex file is then included into the main document using the \include directive.

The main problem is that when edited the separate .tex files, the syntax highlighting is incorrect. The main tex file which includes all the chapters is correctly highlighted because it contains the preamble and \begin{document} ... \end{document, but since the partial files do not include those statements it is highlighted incorrectly.

Do anyone know of a quick fix for this?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

You can add the following line to your .vimrc file in order to tell vim always to expect LaTeX code (instead of plain TeX code) within .tex files:

let g:tex_flavor = "latex"
share|improve this answer
It works perfectly, I should probably just read the documentation first. Since the solution was so simple. –  pfdevilliers May 11 '12 at 16:22
add comment

Your Answer


