Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The first XML Builder Example for Nokogiri looks like this:

builder = Nokogiri::XML::Builder.new do |xml|
    xml.root {
      xml.products {
        xml.widget {
          xml.id_ "10"
          xml.name "Awesome widget"
        }
      }
    }
 end
 puts builder.to_xml

Even though I have the Ruby Vim files installed, Vim's autoindent flattens the above example like this:

builder = Nokogiri::XML::Builder.new do |xml|
  xml.root {
    xml.products {
    xml.widget {
    xml.id_ "10"
    xml.name "Awesome widget"
  }
  }
  }
end
puts builder.to_xml

Does anybody know how to get Vim to autoindent this correctly?

share|improve this question

I can reproduce this.

The indentation rules are defined in the function GetRubyIndent, which is in /usr/share/vim/vimcurrent/indent/ruby.vim on Linux and Unix systems.

The problem seems to be that GetMSL returns 8 for line 3, but also returns 8 rather than 12 for line 4.

If you have a bit of time, have a look at the source code and try to find and fix the problem.

If not, you might like to report it as a bug at the RubyForge Vim/Ruby project site.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .