Search code examples
rubyminereformatting

How to edit RubyMine reformat code


everyone.

Wanted to know, is it possible to edit, how RubyMine reformats code, so that code like this:

some_object = {
      :long_named_item => 'value',
      :short_item => 'value'
    }

user = User.create!({
                     :nickname => 'value',
                     :age => 18
                    })

gets reformated like this:

some_object = {
      :long_named_item => 'value',
      :short_item      => 'value'
    }

    user = User.create!({
                          :nickname => 'value',
                          :age      => 18
                        })

or, even with js:

var some_variable = {
    'long_named_item': 'value',
    'short_item': 'value'
}

to:

var some_variable = {
    'long_named_item': 'value',
    'short_item':      'value'
}

Notice the spacing between hash item name and value

My friend said, that SublimeText does this with python code, so wanted to know, is this possible in RubyMine.


Solution

  • After looking at formatting options in RubyMine, i found exactly, what i wanted.. For Javascript, the value i had to chose for "Align object properties" was "on value" And for Ruby i had to tick option "Align right parts of assigments or hashes"

    Both were under:

    Settings (Preferences on Mac) | Code Style | YOUR_LANGUAGE | Other
    

    Thanks to LazyOne