# Auto indentation problem; little help please :)

**URL:** <https://www.ruby-forum.com/t/auto-indentation-problem-little-help-please/68761>\
**Category:** Ruby\
**Created:** [September 15, 2006, 6:07am UTC](https://www.ruby-forum.com/t/auto-indentation-problem-little-help-please/68761 "2006-09-15T06:07:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![skeptic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@skeptic](https://www.ruby-forum.com/u/skeptic)\
**Post date:** [September 15, 2006, 6:07am UTC](https://www.ruby-forum.com/t/auto-indentation-problem-little-help-please/68761/1 "2006-09-15T06:07:25Z")

</div>

Hi,

I’m new to ruby and irb and am hoping someone can give me a helping  
hand. Even this issue is small, it’s annoying to me.

I’m running irb 0.9.5 on OS X 10.4 within an iterm terminal. I’m doing  
all this on a MacBook Pro laptop.

I’ve got auto-indenting set and readline support.

The annoying indent problem is, when I type code into irb, it indents as  
follows:

* * *

## gary-churchs-computer:~ gary$ irb irb(main):001:0\> class Song irb(main):002:1\> def initialize(name, artist, duration) irb(main):003:2\> @name = name irb(main):004:2\> @artist = artist irb(main):005:2\> @duration = duration irb(main):006:2\> end irb(main):007:1\> end =\> nil irb(main):008:0\>

with the “end”'s not lining up below the correct upper lines (here “def”  
and “class”, respectively.) In all the examples I’ve seen in the book,  
everything (including comments) line up correctly.

When I type in the code, at the end of a line, I simply hit “return” to  
get to the next line.

Any ideas for this minor buy annoying problem?

Thanks much,  
Gary

---

<div class="post-metadata">

**Author:** ![skeptic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@skeptic](https://www.ruby-forum.com/u/skeptic)\
**Post date:** [September 15, 2006, 6:16am UTC](https://www.ruby-forum.com/t/auto-indentation-problem-little-help-please/68761/2 "2006-09-15T06:16:06Z")

</div>

Gary Church wrote:

> Hi,
> 
> I’ve got auto-indenting set and readline support.
> 
> with the “end”'s not lining up below the correct upper lines (here “def”  
> and “class”, respectively.) In all the examples I’ve seen in the book,  
> everything (including comments) line up correctly.

It is not really possible to do because irb does not know  
when you are going to end a block. Once you have entered  
the end, the only way to get it to line up right would  
be to use terminal controls through Curses or something  
and it probably is not worth the trouble.

I would recommend to just try to ignore it or, if you  
want, turn autoindent off and enter the whitespace  
yourself 🙂

> Thanks much,  
> Gary

---

<div class="post-metadata">

**Author:** ![skeptic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e480ec/32.png) [@skeptic](https://www.ruby-forum.com/u/skeptic)\
**Post date:** [September 15, 2006, 4:47pm UTC](https://www.ruby-forum.com/t/auto-indentation-problem-little-help-please/68761/3 "2006-09-15T16:47:37Z")

</div>

Eero S. wrote:

> It is not really possible to do because irb does not know  
> when you are going to end a block. Once you have entered  
> the end, the only way to get it to line up right would  
> be to use terminal controls through Curses or something  
> and it probably is not worth the trouble.
> 
> I would recommend to just try to ignore it or, if you  
> want, turn autoindent off and enter the whitespace  
> yourself 🙂

Thanks for the reply.

Seemed that way to me too but I’ve seen many examples in  
books and on the net where, apparently, auto-indent was on  
and the “end” 's lined up properly. Seemed strange to me and  
that prompted the post.

Thanks again,  
Gary.
