autoindenting ruby

M

Martin DeMello

Something most of the "IDE roundup" threads seem to pass over lightly
is the autoindent feature - for me, that is the make-or-break feature.
How do the various IDEs and editors out there stack up? I'm pretty
happy with gvim and the vim-ruby package, though there are still a few
places where it messes up (yes, I have filed bugs).

martin
 
F

forgottenwizard

Something most of the "IDE roundup" threads seem to pass over lightly
is the autoindent feature - for me, that is the make-or-break feature.
How do the various IDEs and editors out there stack up? I'm pretty
happy with gvim and the vim-ruby package, though there are still a few
places where it messes up (yes, I have filed bugs).

martin

Have you looked into the indent utility? I know it works with C well,
and you can use diffrent "styles" that it comes with. It isn't in an
IDE, but you should be able to run it in a decent IDE.
 
M

Martin DeMello

Have you looked into the indent utility? I know it works with C well,
and you can use diffrent "styles" that it comes with. It isn't in an
IDE, but you should be able to run it in a decent IDE.

That misses the "hit return and have the next line indented properly"
bit that makes vim (and emacs, no doubt) such a pleasure to use.

martin
 
V

Vasyl Smirnov

In Emacs I use the following function, found somewhere on the net.

(defun iwb ()
"Indent whole buffer."
(interactive)
(delete-trailing-whitespace)
(indent-region (point-min) (point-max) nil)
(untabify (point-min) (point-max)))

it relies on ruby-mode.el to indent Ruby sources.
Probably something similar can be written/found for vim.
 
J

Jari Williamsson

Martin said:
Something most of the "IDE roundup" threads seem to pass over lightly
is the autoindent feature - for me, that is the make-or-break feature.
How do the various IDEs and editors out there stack up? I'm pretty
happy with gvim and the vim-ruby package, though there are still a few
places where it messes up (yes, I have filed bugs).

NetBeans 6 has auto-formatting of regions, auto-indenting when pressing
Enter key, different indent settings for start lines and continuations,
option to reformat comment blocks, option to format HTML within RHTML
blocks.

And probably much more. I'm still very much a NB student, learning new
NB tricks every day. Today I learned about autowarn (and auto-fix) for
camelCase variables, or for constants that lacks all-caps, etc. But the
coolest one today was to press Ctrl+Shift+Space (on Windows) when I'm in
a comment, I get an instant RDoc version of that comment block displayed
in a window. Great time saver!


Best regards,

Jari Williamsson
 
M

MonkeeSage

read the code above again and tell me that 'gg=G' does all that...

For vim, that function would be something like...

" Indent whole buffer.
function! IndentFile()
let cursor = line('.')
exe ":%s/\\s\\+$//"
exe "norm gg=G".cursor."G"
exe ":%retab"
endfunction

Regards,
Jordan
 
E

Eric Promislow

Something most of the "IDE roundup" threads seem to pass over lightly
is the autoindent feature - for me, that is the make-or-break feature.
How do the various IDEs and editors out there stack up? I'm pretty
happy with gvim and the vim-ruby package, though there are still a few
places where it messes up (yes, I have filed bugs).

martin

Komodo does auto-indent for Ruby, including Ruby code in RHTML blocks.

http://www.activestate.com/komodo

Disclaimer: I'm in charge of the Ruby integration in Komodo.

- Eric
 
H

Huw Collingbourne

Ruby In Steel does smart auto-indenting of Ruby and embedded Ruby (in
HTML), also it can reformat an entire document or a marked block to
adjust the code indentation.

http://www.sapphiresteel.com

Following Eric's disclaimer (above), I guess I should point out that I
am the Technology Director of Ruby In Steel ;-)

best wishes
Huw
 

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,274
Messages
2,571,366
Members
48,052
Latest member
EvaW192252

Latest Threads

Top