How to set the default to unfolded when you open a file?

Suan picture Suan · Nov 29, 2011 · Viewed 16.6k times · Source

In my .vimrc I've put set foldmethod=syntax to enable folding of methods etc. However, I don't like the default that everytime I open a file, the whole thing is folded. Is there a way to enable foldmethod, yet have files unfolded when I open them?

Answer

Walter picture Walter · Nov 29, 2011

You can put this in your .vimrc: au BufRead * normal zR

It declares an automatic command (au), triggered when a buffer is read (BufRead), matching all files (*) and executes the zR (opens all folds) command in normal mode.