3

I added set foldmethod=syntax to my .vimrc, but it automatically folds whenever a new file is opened. Is there a way to prevent auto-folding and just use za to toggle?

1
  • Thanks @grodzik your link solved my problem! However, not sure about the duplication. 🤔 Should I delete this one or keep it?
    – ogirginc
    May 7 '17 at 19:10
1

As it turns out, I need nofoldenable in .vimrc too:

set foldmethod=syntax
set nofoldenable
3
  • 1
    You might find 'foldlevelstart' more useful.
    – Antony
    May 7 '17 at 19:37
  • 1
    @Antony do you suggest using set foldlevelstart=99? Does it make any difference compared to nofoldenable? Couldn't find any advantages...
    – ogirginc
    May 8 '17 at 7:41
  • It's a global option that specifies the starting 'foldlevel' when editing a new file. 'foldenable' is window local and toggles folds on or off.. You can of course use both and toggle 'foldenable' with zi.
    – Antony
    May 8 '17 at 10:47

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