auto indentation problem; little help please :)

G

Gary Church

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
 
E

Eero Saynatkari

Gary said:
Hi,

<snip />

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

<snip />

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 :)
 
G

Gary Church

Eero said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,933
Members
47,472
Latest member
blackwatermelon

Latest Threads

Top