Code reformatter to add spacing around all operators

I was pleased to see the inclusion of a new feature in Ruby 4, namely the "Spaces around arrows" checkbox in the code style preferences pane. This is a feature I requested, but I am now wishing I had asked for the same thing for all operators. If you agree with me, please vote for the youtrack issue I created:

http://youtrack.jetbrains.com/issue/RUBY-10510

I have a habit of typing without spaces and hitting the keyboard shortcut for Reformat Code regularly. The less times I have to hit the spacebar, the less carpel tunnel I have later!

4 comments
Comment actions Permalink

A code formatter I just used on a bunch of ruby files is:

http://www.arachnoid.com/ruby/rbeautify.rb.txt

It does a better job of selecting the beginning of comments in the code than the normal Rubymine 3.2.4 code formatter.

I haven't downloaded the new 4.0.1 version yet. I'm thinking it may have the same formatter as 3.2.4

0
Comment actions Permalink

Is there a way to assign such a script to a keyboard shortcut such that I can run it periodically as I am coding? If not then I'm afraid it wouldn't satisfy me. By the way, if you have a suggestion for how to improve the built-in code reformatter in RubyMine with regard to comments, create an issue in YouTrack. I would vote for it.

0
Comment actions Permalink
Is there a way to assign such a script to a keyboard shortcut such that I can run it periodically as I am coding?


Use External Tools for that:

  • Settings | External Tools -- create such "command/action"
  • Settings | Keymap -- assing custom shortcut to that external tools entry
0
Comment actions Permalink

I got it to work, unfortunately

  • It doesn't add spacing around operators or arrows (=>).
  • I must save the file I'm working on before I run the external tool.
  • I find that the script doesn't work every time I run it. It's as if there's some sort of time delay. I can work a bit more and then run it again and then it works.


Although I very much appreciate your suggestion I once again ask for support in improving the built-in code reformatter! It's actually very good IMO, it just needs a few more features.

0

Please sign in to leave a comment.