eRuby indenting capabilities

Tim Pope vim-ruby-devel at tpope.info
Mon Dec 4 12:05:41 EST 2006


On Tue, Dec 05, 2006 at 02:00:17AM +1100, Doug Kearns wrote:
> Tim,
> 
> I was just giving the new indent script a quick test drive prior to the
> next release and noticed that the following example doesn't work as I'd
> expect.
> 
> <%
> if true
> %>
> foobar
> <%
> end 
> %>
> 
> is indented as:
> 
> <%
>   if true
> %>
> foobar
> <%
>     end
>   %>

First, the end block should of course be

<%
  end
%>

This is what I get.  Do your results differ or was this a copy and
paste error?

> It also appears that the Ruby code will only be indented correctly when
> the <%,%> delimiters are on lines by themselves?
> 
> eg. the following isn't transformed at all when running the
> filter/indent motion over it.
> 
> <% if true
> foobar
> end %>
> 
> 
> Am I misunderstanding its current capabilities?

Pretty much :).  I've supported the most common conventions.  For
example, your first example would work fine if written as

<% if true %>
  foobar
<% end %>

It would of course be ideal to support your examples as well but
implementing them would require some heavy modifications to
indent/ruby.vim (and perhaps indent/html.vim as well).  Since they
are apparently quite rare in the code I've worked with, I'm cheerfully
refraining from the task.

Cheers,
Tim


More information about the vim-ruby-devel mailing list