So I started a big project which has multiple files that are included in the main file. I'm using vim, specifically with the vim-latex plugin.

The problem is that vim-latex doesn't work for the standalone .tex files (because they lack a preamble). And by that I mean that the shortcuts don't work (like the F9 autocompletion, F5, etc; I don't really care that much about the compilation commands). How to I deal with this?

I did some research and it seems to me that one of the solutions is to use a main.tex.latexmain file. Maybe I'm missing something obvious but I'm not sure what goes in that file. According to the docs it should be Vim commands, but I honestly have no idea which commands and I couldn't find one single example online.

  • What do you mean exactly with "vim-latex doesn't work for standalone files"? Are you unable to edit them? Or do you want to compile the main file while you are editing a standalone file? Or do you want to compile the standalone file without compiling the main file?
    – Marijn
    May 13, 2020 at 12:58
  • @Marijn I mean the shortcuts don't work. Sorry I should have specified better. I'll edit the question
    – TomCho
    May 13, 2020 at 16:21

1 Answer 1


It seems like vim is detecting the incorrect file type. A blank .tex document will have the vim file type plaintex, where as a LaTeX document has file type tex. It would appear that vim-latex does not run on plaintex. There are at least two ways to force vim to read it as a tex file type:

  1. Add the following line at the top of the tex file to change the file type detected by vim:
% vim: set filetype=tex :
  1. Add an auto command to your .vimrc file to make vim-latex run in all .tex files:
autocmd BufNewFile,BufRead *.tex set filetype=tex

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.