# A trivial formatting question

**URL:** <https://www.ruby-forum.com/t/a-trivial-formatting-question/165186>\
**Category:** Ruby\
**Created:** [April 9, 2009, 11:52pm UTC](https://www.ruby-forum.com/t/a-trivial-formatting-question/165186 "2009-04-09T23:52:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjsquire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@rjsquire](https://www.ruby-forum.com/u/rjsquire)\
**Post date:** [April 9, 2009, 11:52pm UTC](https://www.ruby-forum.com/t/a-trivial-formatting-question/165186/1 "2009-04-09T23:52:54Z")

</div>

Hi all from a 30-year veteran, but rather a Ruby noob,

I’ve been looking around for a Ruby IDE, and came across the soon to  
be released RubyMine. It looks to be a promising program, with a very  
nice code reformatter.

One thing irks me: It doesn’t indent the clauses of a case statement,  
but prints the 'when’s flush with the ‘case’ and ‘end’ keywords. This  
complicates discerning the scope of the statement quickly. I went  
back to ‘Programming Ruby’ and found the same formatting, which I find  
somewhat barbaric.

My question is, how many of you indent when clauses? Does it matter  
to you at all? Is there a package that prettifies Ruby code, even if  
not in an editor, and is configurable?

Thanks,

Bob Schaaf

---

<div class="post-metadata">

**Author:** ![rjsquire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@rjsquire](https://www.ruby-forum.com/u/rjsquire)\
**Post date:** [April 10, 2009, 12:34am UTC](https://www.ruby-forum.com/t/a-trivial-formatting-question/165186/2 "2009-04-10T00:34:15Z")

</div>

Robert S. wrote:

> Hi all from a 30-year veteran, but rather a Ruby noob,
> 
> I’ve been looking around for a Ruby IDE, and came across the soon to  
> be released RubyMine. It looks to be a promising program, with a very  
> nice code reformatter.
> 
> One thing irks me: It doesn’t indent the clauses of a case statement,  
> but prints the 'when’s flush with the ‘case’ and ‘end’ keywords. This  
> complicates discerning the scope of the statement quickly. I went  
> back to ‘Programming Ruby’ and found the same formatting, which I find  
> somewhat barbaric.
> 
> My question is, how many of you indent when clauses? Does it matter  
> to you at all? Is there a package that prettifies Ruby code, even if  
> not in an editor, and is configurable?
> 
> Thanks,
> 
> Bob Schaaf  
> always leave ‘when’ indented to the same level as the case statement,  
> much as I would indent elsif to the same level as the if statement. So  
> my case/whens look like this:

case var  
when ‘val’  
some code  
when ‘otherval’  
different code  
when ‘foo’  
bar  
else  
oh no!  
end

(obviously this is not quite valid ruby code, but you get the idea)

As for an editor for your use, it depends on your platform, of course.  
Linux? OS X? Windows?

---

<div class="post-metadata">

**Author:** ![rjsquire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@rjsquire](https://www.ruby-forum.com/u/rjsquire)\
**Post date:** [April 10, 2009, 3:55am UTC](https://www.ruby-forum.com/t/a-trivial-formatting-question/165186/3 "2009-04-10T03:55:47Z")

</div>

On Apr 9, 5:50 pm, Robert S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> somewhat barbaric.
> 
> My question is, how many of you indent when clauses? Does it matter  
> to you at all? Is there a package that prettifies Ruby code, even if  
> not in an editor, and is configurable?
> 
> Thanks,
> 
> Bob Schaaf

something = 2  
SciTE = case something  
when 1; 1  
when 2; 4  
else 0  
end  
puts SciTE # =\> 4 # Had to manually ex-dent this line; indents above  
were automatic.

I love SciTE because it also executes in a separate pane by simply  
pressing F5. Automatically saves current code before compiling and  
executing. It’s color coding is excellent IMHO.

Good luck,  
Richard
