TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.