Can I get vim to correctly indent this Ruby code (Nokogiri)?

Posted by Nathan Long on Super User See other posts from Super User or by Nathan Long
Published on 2011-02-21T20:26:22Z Indexed on 2011/02/21 23:27 UTC
Read the original article Hit count: 254

Filed under:
|
|

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?

© Super User or respective owner

Related posts about vim

Related posts about ruby