1

Hi I am trying out vimtex on a multi-file project, and so far I was liking it a lot. However, I just found out that vimtex commands (\lv, \lt, \li, etc) work correctly when used while editing the main file, but have no effect when editing imported files.

Now since most of the work happens in imported files this is quite a big problem. By the way, continuos compilation does not stop when switching to imported files, so I can still see changes in real-time.

I am on ubuntu, using vim 8.0 compiled with --with-features=huge and using zathura for pdf visualization.

I have tried creating an empty main.tex.latexmain file and also putting all the imported files in the same folder of main file.

Does anyone know why this happens?

6
  • 1
    Are the filetypes being set correctly? Thats my first thought if the mappings arent working.
    – D. Ben Knoble
    Dec 26, 2017 at 0:56
  • @DavidBenKnoble I'm not sure I know what you are referring to. I have some .tex files in a folder and I import them in the main.tex. Is there anything else I should do?
    – ClonedOne
    Dec 26, 2017 at 1:46
  • 1
    Check the output of set filetype (i think) when you have the imported files open, and then check the output of map if the filetype is correctly set to tex or latex.
    – D. Ben Knoble
    Dec 26, 2017 at 2:25
  • You probably need to add let g:tex_flavor = 'latex'. Dec 26, 2017 at 8:38
  • @DavidBenKnoble Checked the filetype and it was tex, strangely mapactually showed the correct mapping but they did not work.
    – ClonedOne
    Dec 26, 2017 at 23:55

1 Answer 1

3

Short answer: add let g:tex_flavor = 'latex' to your vimrc file.


So, more details. First: This problem is not related to vimtex. vimtex depends on the internal tex plugin, e.g. for filetype detection and syntax, and this particular problem is with how the internal tex plugin recognizes the filetype.

To be more specific, the internal tex plugin differs between different flavors: plain, context, and latex. Which one is used depends on two things:

  1. The header of the loaded file, and
  2. The value of the g:tex_flavor option.

The g:tex_flavor option is used to set the "default" style, which is used when the flavor can not be decided from the header. The header is parsed for two things: Either a %&<format> string, or some keywords that identify the flavor. If you don't set g:tex_flavor, it defaults to plaintex.

For more details, see:

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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