繁体   English   中英

如何通过空行折叠vim(rspec示例)?

[英]How do I fold in vim through blank lines (rspec example)?

我试图让vim以我想要的方式折叠,但是有麻烦。

我在我的一些测试代码中使用了空格来使其更清晰,我无法通过空行来获取vim。

我有的:

describe 'Troubles' do

  describe 'Home' do

    let( :troubles ) { be_over}

    describe 'Pain' do
      it "shouldn't be this hard" { puts "but it is" }
    end
  end
end

它希望它折叠如下:

describe 'Troubles' do

  describe 'Home' do
+--- 6  lines: -------------------
  end
end

有什么方法可以做到这一点?

这是我的.vim折叠设置

set tabstop=2
set shiftwidth=2
set expandtab

set foldmethod=indent
set foldnestmax=10
set nofoldable
set foldlevel=1

你用什么折叠方法? 使用缩进折叠方法对我来说很好(它折叠5行,因为第一行是一个空白的无痕线。

set foldmethod=indent

如果你有兴趣专门为RSpec文件折叠,这里有一个小的RSpec foldexpr插件我在周末聚在一起。 它的功能很大(~150 SLOC),但它只是按我喜欢的方式处理折叠( 例如,折叠包含一个块之后的尾随新行,这不是你的问题,但非常接近)。

这是示例代码的折叠列:

-    describe 'Troubles' do
|
|-     describe 'Home' do
||
||       let( :troubles ) { be_over}
||
||-      describe 'Pain' do
|||        it "shouldn't be this hard" { puts "but it is"}
|||      end
||     end
|    end

这就是折叠的样子:

describe 'Troubles' do

- describe 'Home' ---------------------------------------------------- [4] -
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM