Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 557
Suan Avatar asked Nov 29 '11 18:11

Suan


2 Answers

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.

like image 78
Walter Avatar answered Oct 01 '22 21:10

Walter


set foldlevel=99 

should open all folds, regardless of method used for folding. With foldlevel=0 all folded, foldlevel=1 only somes, ... higher numbers will close fewer folds.

like image 25
Rook Avatar answered Oct 01 '22 22:10

Rook