Ruby Source code Auto-Formatter [closed]
Asked Answered
C

2

20

What is the best option? I found:

but they both seem slightly outdated. Special support for Rails (Knowing which files to format automagically and some other cool things) would be a plus, and a git hook script.

Coachandfour answered 10/6, 2013 at 20:58 Comment(5)
well - the "best" option is justifiable to speculate on.. but I use my favorite editor, Eclipse. I have a custom formatter enabled, and i just do Ctrl+Shift+F and voila.Decrescendo
Sublime Text 2 can "reindent" Ruby code, as can Vim.Cromlech
I would love to see something as comprehensive as perltidy in ruby.Creatural
rubocop is currently implementing some of this functionality. It's a style checker, but with optional auto-fixing of style-warnings. It's not nearly far enough to put it here as answer though ;)Emmott
The first link is now dead.Cromlech
B
21

There is RuboCop:

gem install rubocop
rubocop -a

It will also fix all the common mistakes.

Bypass answered 27/6, 2014 at 17:3 Comment(0)
A
1

Just use vim, in command mode press gg=G

  1. gg - move cursor to the beginning of your file
  2. = - reindent
  3. G - till the end of file
Apologia answered 22/6, 2014 at 23:3 Comment(1)
formatting is more than only indentationHousetop

© 2022 - 2024 — McMap. All rights reserved.