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?
相关问题
- Emacs shell: save commit message
- Lazily Reading a File in D
- How to change the first two uppercase characters o
- Insert text into current buffer from function
- C# How do I create code to set a form back to defa
相关文章
- 如何让 vim 支持 .cshtml 文件的代码高亮
- How to replace file-access references for a module
- Auto-save in VIM as you type
- How can I use gcc's -I command to add recursiv
- Why is file_get_contents faster than memcache_get?
- Transactionally writing files in Node.js
- Vim: overloaded mapping for multiple modes
- How to use relative line numbering universally in
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.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 thezR
(opens all folds) command in normal mode.Adding this to your
.vimrc
will temporarily disable folding when you open the file, but folds can still be restored withzc
If you want a way to have it display unfolded as soon as it is opened, you can use
set foldlevelstart=99
as a lot of answers explained.But, if you just want to see them unfolded, you can just press
zi
and it will unfold everything. Another,zi
will close them back.In
.vimrc
add an autocmd forBufWinEnter
to open all folds automatically like this:That tell vim to execute the
silent :%foldopen!
after openingBunWinEnter
event (see:h BufWinEnter
). Thesilent %foldopen!
will executefoldopen
on the whole buffer thanks to the%
and will open all folds recursively because of the!
. Any eventual error message will be suppressed bysilent
. (You could get error messages likeE490: No fold found
if the buffer actually didn't contain any fold yet)Note: You could use
BufRead
instead ofBufWinEnter
but then if the file has a modeline that enables the folding that will override this autocmd. I meanBufRead
autocmds run before the modeline is processed andBufWinEnter
will run them after. I find the later to be more usefulYou could map it to keys to enable it. For example,
Then while in normal mode hit the ",f" key combination