vim / NERDtree / Folding - 它能记住折叠的状态吗?

发布于 2024-12-01 22:34:37 字数 520 浏览 3 评论 0原文

有没有办法让 NERDtree 在从一个缓冲区切换到另一个缓冲区时记住折叠的状态?

这是我完整的 .vimrc:

set ignorecase
set scs
let perl_fold=1
hi Folded cterm=bold ctermfg=yellow ctermbg=lightblue
set modeline

cabbr N NERDTree

这是我所观察到的:

  • 启动 NERDTree
  • 选择一个文件并使用空格键在新缓冲区中打开它(所有折叠都关闭)
  • 在缓冲区中打开一些折叠
  • C-w w 返回 NERDTree
  • 选择另一个文件,使用空格键打开它
  • C-w w 回到 NERDTree
  • 选择第一个文件,按空格键

我原来打开的折叠现在关闭了。 我正在编辑 perl 文件,因此 perl_fold=1 有效。 我希望当我从一个文件跳到另一个文件时能够记住折叠的状态。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不吻晚风 2024-12-08 22:34:37

您确定 映射正确吗?我没有看到它在 NERDTree 的帮助中列出。

不管怎样,NERDTree 与你的缓冲区内容或状态无关,它只是一个文件浏览器。

如果没有某种机制来保持缓冲区的状态,当您打开新文件时,您的折叠就会丢失。幸运的是,您可以将 set hide 添加到您的 .vimrc 中。

使用它,缓冲区会保留下来,直到您使用 :bd 显式删除它们为止。这意味着,通过使用 NERDTree 或使用 :b 返回到之前的文件时,您仍然保留折叠。

Vim wiki 有 nice 有关缓冲区的页面

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文