Given a source file with bad indentation, incorrect white space management, and so on. How do I reformat the code such a file and apply the Ruby's style guide (if present)?
How do I reformat ruby code from the command line?
Asked Answered
This should be a task of your editor. In vim (configured for Ruby), just press gg=G
xD
A Ruby script that does it is available at: http://www.arachnoid.com/ruby/rbeautify.rb.html
That was exactly the script I was looking for (thnx). Tried it, commit 15c34bf shows an example. –
Supposal
btw I suspect TextMate ships with built-in Ruby support, so that a plus. VIM will do it, but that needs adjustment. I wanted something that's available from the command line to prevent the editor minefield (for TextMate, you need a licence, for VIM you need plugins, etc.). –
Supposal
Haven't tried it myself:
This should be a task of your editor. In vim (configured for Ruby), just press gg=G
xD
A Ruby script that does it is available at: http://www.arachnoid.com/ruby/rbeautify.rb.html
That was exactly the script I was looking for (thnx). Tried it, commit 15c34bf shows an example. –
Supposal
btw I suspect TextMate ships with built-in Ruby support, so that a plus. VIM will do it, but that needs adjustment. I wanted something that's available from the command line to prevent the editor minefield (for TextMate, you need a licence, for VIM you need plugins, etc.). –
Supposal
© 2022 - 2024 — McMap. All rights reserved.