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?


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"
  • It works perfectly, I should probably just read the documentation first. Since the solution was so simple. May 11 '12 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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