Search code examples
vimfolding

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


I am trying to get vim to fold the way I want, but an having troubles.

I use blank spaces in some of my test code to make it more legible, and I can't get vim to fold through the blank lines.

What I have:

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

and it want it to fold like:

describe 'Troubles' do

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

Any way to get that done?

Here is my .vim setup for folding

set tabstop=2
set shiftwidth=2
set expandtab

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

Solution

  • what folding method are you using? using an indent fold method works fine for me (well it folds 5 lines since that first one is a blank unindented line.

    set foldmethod=indent