vim / NERDtree / folding - can it remember the state of folds?
Is there a way to make NERDtree remember the state of folds when switching from buffer to buffer?
Here the my complete .vimrc:
set ignorecase
set scs
let perl_fold=1
hi Folded cterm=开发者_如何学运维bold ctermfg=yellow ctermbg=lightblue
set modeline
cabbr N NERDTree
Here is what I am observing:
- start NERDTree
- select a file and use spacebar to open it in a new buffer (all folds are closed)
- open some folds in the buffer
- C-w w back to NERDTree
- select a different file, use spacebar to open it
- C-w w back to NERDTree
- select the first file, hit spacebar
The folds I had opened originally are now closed. I am editing perl files,so the perl_fold=1 is in force. I'd like the state of the folds to be remembered as I bounce around from file to file.
Are you sure about the <Space>
mapping? I don't see it listed in NERDTree's help.
Anyway, NERDTree has nothing to do with your buffers content or state, it's only a file explorer.
Without some mechanism to keep state of your buffers your folds are lost when you open a new file. Luckily you can add set hidden
to your .vimrc.
With it buffers are kept around until you explicitly delete them with :bd
. This means that you still have your folds when going back to your previous file, either by using NERDTree or by using :b <Tab>
.
The Vim wiki has nice pages about buffers.
精彩评论