I have Vim on Ubuntu 18.04 and I am trying to use the vim-latex package. By typing :set rtp? on Vim I get the following output:


From that, it seems to me that the vim-latex package is indeed installed. However, I haven't been able to make the package start automatically once I open a latex file on vim. I am assuming (maybe incorrectly, so I would thank any corrections to my thinking) that this is happening because I haven't completed step 2 of the vim-latex installation as in their Installation Instructions page, which includes adding filetype plugin on to my ~/.vimrc.

By typing :version on Vim, I get the following output:

system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"

Inspecting my system, I couldn't find $HOME/.vimrc, so I created one. I could find ~/.vim/vimrc, but my system did not let me make changes to it. Nevertheless, when I start a .tex file on Vim I believe it still does not start the package as I don't see anything similar to what is describe in this tutorial.

Some further details: By running :filetype I get filetype detection:ON plugin:ON indent:ON. I was getting indent:OFF before adding the line for indetation in my $HOME/.vimrc, so I believe it is getting the right file.

By running :verbose set ft? I get:

Defined last time in /usr/share/vim/vim80/autoload/dist/ft.vim

By running scriptnames I get:

1: /usr/share/vim/vimrc
2: /usr/share/vim/vim80/debian.vim
3: /usr/share/vim/vim80/syntax/syntax.vim
4: /usr/share/vim/vim80/syntax/synload.vim
5: /usr/share/vim/vim80/syntax/syncolor.vim
6: /usr/share/vim/vim80/filetype.vim
7: ~/.vimrc
8: /usr/share/vim/vim80/ftplugin.vim
9: /usr/share/vim/vim80/indent.vim
10: /usr/share/vim/vim80/plugin/getscriptPlugin.vim
11: /usr/share/vim/vim80/plugin/gzip.vim
12: /usr/share/vim/vim80/plugin/logiPat.vim
13: /usr/share/vim/vim80/plugin/manpager.vim
14: /usr/share/vim/vim80/plugin/matchparen.vim
15: /usr/share/vim/vim80/plugin/netrwPlugin.vim
16: /usr/share/vim/vim80/plugin/rrhelper.vim
17: /usr/share/vim/vim80/plugin/spellfile.vim
18: /usr/share/vim/vim80/plugin/tarPlugin.vim
19: /usr/share/vim/vim80/plugin/tohtml.vim
20: /usr/share/vim/vim80/plugin/vimballPlugin.vim
21: /usr/share/vim/vim80/plugin/zipPlugin.vim
22: ~/.vim/pack/bundle/start/vim-latex-1.10.0/plugin/SyntaxFolds.vim
23: ~/.vim/pack/bundle/start/vim-latex-1.10.0/plugin/filebrowser.vim
24: ~/.vim/pack/bundle/start/vim-latex-1.10.0/plugin/imaps.vim
25: ~/.vim/pack/bundle/start/vim-latex-1.10.0/plugin/remoteOpen.vim
26: /usr/share/vim/vim80/autoload/dist/ft.vim
27: /usr/share/vim/vim80/syntax/plaintex.vim
28: /usr/share/vim/vim80/syntax/initex.vim
29: /usr/share/vim/vim80/ftplugin/plaintex.vim
30: /usr/share/vim/vim80/ftplugin/initex.vim

I will be very grateful to anyone that can help me figure out what's happening. I would like to apologize in advance if I did not provide all the details needed (I am new to Vim). Let me know if you need more information. Thanks!

OBS: Following this I have added the tree path of my vim-latex installation if it helps:

~/.vim$ tree -L 5
├── pack  
│   └── bundle  
│       └── start  
│           └── vim-latex-1.10.0  
│               ├── compiler  
│               ├── doc  
│               ├── ftplugin  
│               ├── indent  
│               ├── latextags  
│               ├── ltags  
│               ├── Makefile  
│               ├── Makefile.in  
│               ├── plugin  
│               ├── README.md  
│               └── vim-latex.metainfo.xml  
├── tags  
└── tags-te  
  • 1
    When you use the :filetype command to check whether it's enabled, do you see filetype detection:ON plugin:ON indent:ON? When you open a LaTeX file, what does :verbose set ft? tell you? After opening the LaTeX file, use the :scriptnames command to see which Vim scripts and plug-ins were loaded. Please edit the question to include this information.
    – filbranden
    Commented Sep 13, 2020 at 17:46
  • Welcome to Vi and Vim!
    – filbranden
    Commented Sep 13, 2020 at 17:55
  • 1
    @filbranden, thanks! I have edited my question as you asked.
    – RobertoAS
    Commented Sep 14, 2020 at 2:08
  • Not being able to edit ~/.vim/vimrc is concerning, though likely irrelevant to the question. I prefer to keep my vimrc there because then all my vim files are in one directory
    – D. Ben Knoble
    Commented Sep 14, 2020 at 12:52

2 Answers 2


The problem you're having is that your file is being recognized as filetype=plaintex, which means TeX (or '"plain" TeX) and not LaTeX, and the latex-suite plug-ins only enable most of their commands on LaTeX files. LaTeX files are identified by filetype=tex (which can indeed seem quite confusing.)

Since files with the extension *.tex can be TeX or LaTeX (or even the perhaps lesser known ConTeXt), Vim will try to "guess" which is right for a specific file, usually based on the file's contents.

The code implementing this auto-detection can be found in dist#ft#FTtex and it will detect a *.tex file as LaTeX if:

  • Its first line is a comment of the form %&LaTeX.
  • It can find one of \documentclass, \usepackage, \begin{, \newcommand or `\renewcommand' in the first 1000 lines of the file.
  • Otherwise, if the global variable g:tex_flavor is set to 'latex'.

My recommendation is that, if you plan to use LaTeX exclusively or almost exclusively, then setting the g:tex_flavor variable in your vimrc is the best approach. That will also help ensure that new *.tex files you create will already be recognized as LaTeX files, before they have any content that triggers the auto-detection.

Add the following line to your vimrc:

let g:tex_flavor = 'latex'

See also :help ft-latex-plugin.

  • Thanks @filbranden, now I get filetype=tex. I have added let g:tex_flavor = 'latex' to $VIM/vimrc. In order to edit it, I ran sudo vim vimrc (so not being able to edit it was just a matter of lack of permission for my user). I am now struggling with something else, as I can't find Tex-Suite > Templates to insert the templates as explained in the vim-latex tutorial here. However, I guess I should start a new question to solve this instead of editing this one, right?
    – RobertoAS
    Commented Sep 14, 2020 at 15:21
  • Yes, please ask a new question. Please note that $VIM/vimrc is the "global" vimrc file and probably not the one you should be changing, since it's likely to be overwritten when Vim is upgraded. What you want is your user vimrc file, which will be ~/.vimrc or ~/.vim/vimrc (Vim will use the first of these two that it can find.)
    – filbranden
    Commented Sep 14, 2020 at 16:47
  • Thanks @filbraden. I have it updated in my ~/.vimrc too, but for some reason it wasn't working. It only worked when I added it to $VIM/vimrc. But that's good information, I will know where to look at in case I have issues with that in the future.
    – RobertoAS
    Commented Sep 15, 2020 at 1:39
  • 1
    @filbraden, now it is working. I deleted let g:tex_flavor = 'latex' from $VIM/vimrc, but things kept working. Not sure what happened before, but thanks for the help!
    – RobertoAS
    Commented Sep 15, 2020 at 3:39
  • 1
    Thank you very much for this answer ! I ran into the same issue and this resolved it : ) Commented Feb 3 at 14:00

I had the same problem. I solved it by using a (different) plugin to get that functionality, https://github.com/andymass/vim-matchup.

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Friedrich
    Commented Jun 25, 2023 at 16:57

Your Answer

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

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