How to set default unlock when opening a file?

In my .vimrc I set foldmethod=syntax to enable method folding, etc. However, I don't like the default value, which every time I open the file, everything adds up. Is there a way to enable foldmethod , but are there files deployed when they open?

+43
vim file-io default unfold
Nov 29 '11 at 18:54
source share
7 answers
 set foldlevel=99 

must open all folds, regardless of the method used for folding. With foldlevel=0 everything is folded, foldlevel=1 only somes, ... higher numbers will cover fewer bends.

+41
Nov 29 '11 at 19:22
source share
— -

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

Declares an automatic command ( au ) that starts when reading a buffer ( BufRead ), matching all files ( * ) and executing the zR (opens all folds) in normal mode.

+43
Nov 29 '11 at 19:50
source share
 set nofoldenable 

Adding this to your .vimrc temporarily disable folding when you open the file, but folds can still be restored using zc

+11
May 31 '16 at 10:19
source share

In .vimrc add autocmd for BufWinEnter to automatically open all folds as follows:

 autocmd BufWinEnter * silent! :%foldopen! 

Tell vim to execute silent :%foldopen! after opening the BunWinEnter event (see :h BufWinEnter ). silent %foldopen! will execute foldopen in the entire buffer thanks to % and will recursively open all summaries because of ! , Any possible error message will be suppressed silent . (You may receive error messages such as E490: No fold found if the buffer is not actually already compiled)

Note. You can use BufRead instead of BufWinEnter , but then if the file has a model that allows folding that will override this autocmd. I mean BufRead autocmds, which run before the model is processed and BufWinEnter will run them after. I believe a later version will be more useful

+4
May 15 '14 at 7:58
source share

You can add

 set foldlevelstart=99 

into your .vimrc file, and it will start editing any new file with all open folds.

+1
Sep 28 '14 at 8:15
source share

If you want it to be displayed in expanded form as soon as it opens, you can use set foldlevelstart=99 , as many answers are explained.

But, if you just want them to be deployed, you can just press zi and it expands everything. Another, zi will close them.

+1
Dec 17 '15 at 12:12
source share

You can match it with keys to enable it. For example,

 nmap ,f :set foldmethod=syntax<CR> 

Then, when in normal mode, press the key combination ", f"

-one
Nov 29 '11 at 19:21
source share



All Articles