Although the KDE latex tool Kile looks very nice to me, I like use the famous vim editor with its latex-suite to edit my latex files. I got a problem with this editor recently. The problem is that vim can’t invoke my tex file automatically. For instance, there is an empty file called “empty.tex”. If I open it with vim, the latex-suite won’t load automatically. As long as I added some latex keywords like “/usepackage”, vim would recognise this file as latex tex and load the latex-suite.
I searched the vim “filetype plugin manual” and got —
“Vim can detect the type of file that is edited. This is done by checking the
file name and sometimes by inspecting the contents of the file for specific
So it seems that vim detect the latex tex file by the content of the file, not the extension name “tex” . After some searches, I found there are three ways to make sure the latex-suite will be loaded if the file have a tex extension name.
- In the vim when edit the file. Use “: set filetype=tex“
- Put this line “/* vim: set filetype=tex : */” in the file.
- vim ~/.vimrc. add this line: “let g:tex_flavor = “latex”“.
I think the last method is the best.