3

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?

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

1 Answer 1

1

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!
      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.

14
  • 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. Aug 13, 2018 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) Aug 13, 2018 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, 2018 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, 2018 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, 2018 at 5:33

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.