Take the 2-minute tour ×

Emacs 24 ruby-mode insists on indenting if expressions the following way:

    before1 = if params[:before]

Which i find just plain wrong. The expected behavior should be:

    before1 = if params[:before]

That is - the if block should be indented by exactly one level relative to the line in which the if expression starts. Is there any way to achieve this?

share|improve this question
Be more explicit about the difference, especially when it is about white characters. –  sawa Jul 22 '13 at 11:38
See my reply to a more comprehensive version of this question here: stackoverflow.com/a/20733875/615245 –  Dmitry Dec 22 '13 at 20:48
add comment

1 Answer

up vote 0 down vote accepted

I guess you actually meant to say that Emacs aligns the if with the end, which is actually pretty idiomatic in Ruby (and the style enforced by tools like RuboCop). The second indentation style is popular for method class with blocks, but not for expressions like if/unless/case.

Currently there is now way to change this behaviour. There are plans to introduce a more flexible indentation scheme in ruby-mode in the future, but that's not going to happen in the next Emacs release.

At any rate - it's not a bug, it's a feature :-)

share|improve this answer
add comment

Your Answer


