I want all my folds to be expanded when I open a LaTeX file. As per web search I added the following at the end of .vimrc

set nofoldenable
set foldlevelstart=99
set foldlevel=99

But even now its folding. I also added this is to my ftplugin/tex.vim but the results are the same. I am also using the plugin vim-latex.

Any idea on how to fix/ debug this problem?

  • Comments are not for extended discussion; this conversation has been moved to chat. – John O'M. Aug 10 at 0:25

I checked with a minimal example the proposed solution from https://stackoverflow.com/q/16711143 and they work

  1. Put the following into ~/.vim/after/ftplugin/tex.vim:

    setlocal foldlevel=999
  2. Alternatively, you could define in $MYVIMRC:

    augroup latex
      autocmd Filetype tex setlocal foldlevel=999
    augroup END

Question missed mentioning of plugin vim-latex which changes how folding is done and the question has already been raised on stackoverflow https://stackoverflow.com/q/16711143/. Please consider following advice for new questions https://vi.meta.stackexchange.com/a/15/1292.

  • While I respectfully agree with some of the comments, I have zero knowledge about the plug-in system in vim. In addition I did not even notice/remember the usage of vim-latex (I thought some of my other settings were interfering with the folds; hence I asked on help in "debugging" the problem). Once I found that vim-latex was the problem (thanks to the people in chat and my effort on debugging) I tried many things (see chat) none worked. Unfortunately I could not find the soln that you pointed. – knightrider Aug 13 at 17:02
  • For me only your soln2 is working and soln1 (which is the link which is supposed to have the answer) is not working (again some solns works only for some ppl which a genuine reason to repeat questions). But thanks to your answer, it provided one working solution (soln2) – knightrider Aug 13 at 17:03
  • Did you notice the subfolder after in the path specified in solution 1? It is not ~/.vim/ftplugin/tex.vim which you mentioned in your question. In case of neovim, the path would be different. BTW both solutions are copied over. I just improved the second one by the recommendation from Learn Vimscript the Hard Way – Chapt. 14: put autocmd into an augroup and clear the group with autocmd!. Otherwise autocmd's can pile up when sourcing your vimrc during runtime. – Hotschke Aug 14 at 5:01
  • I use tex.stackexchange.com quite a lot. This site has a more strict policy how questions should be posted: questions only with a MWE are accepted so others can reproduce it easily. Most importantly the person who asks is forced to isolate the problem which e.g. helps to only read the needed parts of the relevant manuals. In your case it would have been :h foldmethod and :h latex-folding. Furthermore this allows you to search the web more precisely. IMHO the question on stackoverflow isolated the problem without the need for a mininmal vimrc & pointed to the right help page of vim-latex. – Hotschke Aug 14 at 5:21
  • Just for the record: a link describing how ideally writing a question should be approached: vi.meta.stackexchange.com/a/1326/1292 (start from empty vimrc; following can be helpful for that superuser.com/a/1310444/161119) – Hotschke Aug 14 at 5:33

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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