Aligning Case with When and Else


I'd like to set up RubyMine to line up my case statements as follows by default, but I don't know how.

# Determine US generation name based on birth year
# Case expression tests ranges with ===
generation = case birthyear
                   when 1946..1963: "Baby Boomer"
                   when 1964..1976: "Generation X"
                   when 1978..2000: "Generation Y"
                   else nil

Thank you. :)

Comment actions Permalink

Go to File|Settings|Code Style|Ruby, select "Other" tab and uncheck "indent when case".

Hope this helps, Oleg.

Comment actions Permalink

Sory for bumping old subject. But I have a question: why this option checked by default?

Indent when as deep as case. I know that many would disagree with this one, but it's the style established in both "The Ruby Programming Language" and "Programming Ruby".

And says the same.

Is ruby mine not folloy style-guide or this guides not authoritative?

Comment actions Permalink

I think the only reason is that the default setting for this option was selected before the guide.
And after that nobody actually care to report this problem to us :( All-in-all it is just one time change if you want to follow the guide ;)
I'd suggest you to file a ticket about this in our tracker ( and we will change the setting.



Please sign in to leave a comment.