3

From :help filetype:

If the first line of a *.tex file has the form %&<format> then this determined the file type: plaintex (for plain TeX), context (for ConTeXt), or tex (for LaTeX).
Otherwise, the file is searched for keywords to choose context or tex. If > no keywords are found, it defaults to plaintex. You can change the default by defining the variable g:tex_flavor to the format (not the file type) you use most. Use one of these:
let g:tex_flavor = "plain"
let g:tex_flavor = "context"
let g:tex_flavor = "latex"

If I open a file from the terminal using vim t.tex then run

:set ft?

It returns

filetype=plaintex

This should be filetype=latex shouldn't it?

If I open a previous document (that was written in TexMaker) within vim and run :set ft? it returns filetype=tex. hmm.

I have added let g:tex_flavour = "latex" to my vimrc, but this doesn't seem to make a difference.

I'm not sure what's best here, and what should be the prefered option. I appreciate that the question perhaps part LaTeX part Vim, but the issues I'm having aren't related to LaTeX afaik.

7

When there's not enough information to decide otherwise, 'filetype' is set to the most basic -- plaintex. Your existing file must have had enough content for the detection to determine that it was actually LaTeX, so 'filetype' was set to tex.

The required command to prefer LaTex when there isn't enough information is

let g:tex_flavor = "latex"

Note, that's flavor, not flavour.

  • 2
    argh flavor flavour, whoops. cheers – baxx Mar 20 '15 at 18:40
  • You forgot the extra u in "cheers". -cheerus. – Eric Leschinski Feb 11 '17 at 3:07

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.