Search code examples
keyboard-shortcutssettingsrubymine

Is there a way in RubyMine to move a line 1 line up or down, without skipping lines/blocks or changing indentation?


I have recently needed to switch from using Notepad++ for the majority of code writing/editing to using RubyMine. One of the features present in both np++ and RubyMine is the ability to shift a line (or multiple lines) of code up or down by one line, by pressing ctrl+shift+[up or down].

In np++, this simply moves the line up or down by one, without changing the indentation of that line or the ones around it. In RubyMine, however, this can have unpredictable (to me) and unwanted (to me) effects including: shifting the line up by an entire code block, instead of just 1 line; and shifting a line resulting in the indentation of that line or adjacent lines being altered.

Are there settings I can change or an alternate shortcut that would result in the behaviour I want: shifting a line up (or down) once simply shifts the line up (or down) by 1 line, without any other formatting/indentation changes?

I have tried searching for ways to alter this behaviour (including on this site) without success. Additionally, I have disabled various settings, particularly in the Editor->General->Smart Keys section, but also without success.


Solution

  • On the top left go to File>Settings>Keymap>Code Formating Actions

    From there you can setup your Move Line Down and Move Line Up keybinds.

    There is no default shortcut for them. If you want to use Ctrl+Shift+Up/Down like I did you have to delete the keybinds for Move Statement Up/Down. Probably "move statement" has caused your problems.

    enter image description here