59

I can't make it working, move line up or down doesn't work. When I reset keyboard for VS and applay scheme for Resharper it ask me for this : enter image description here

and if I take first selection , then alt + up switch me between methods, if I use second selection then this combination does not effects.

kosnkov
  • 5,609
  • 13
  • 66
  • 107

3 Answers3

84

Alt+Up is not a ReSharper shortcut to move a line. It most likely belongs to the Productivity Power Tools extension, that has a feature to move one or more (selected) lines.

Personally, I don't like this feature in PPT, since it will just move the line(s), regardless of their scope, causing compilation errors. I much rather use ReSharper's feature of moving blocks of code up or down, by pressing Ctrl + Shift + Alt + / or / - when on the beginning of the line, it will move the entire line or block of code, but can also be used to move entire methods, change the order of parameters, etc.

Igal Tabachnik
  • 31,174
  • 15
  • 92
  • 157
  • using your tip for the resharper method but going to remap the keys to the single alt key binding. – Valamas Feb 19 '15 at 04:09
  • 8
    This does not work for me, via the shortcut keys. Interestingly, it does work via Resharper > Edit > Rearrange Code > Move up/down menu. If I do it via hotkeys it just highlights the code and shows a message "move up/down to move method". Which I just hit hotkey for! – Stephen Price Aug 26 '15 at 06:56
  • 1
    Doesn't work shortcut for me as well, but works from menu – MikhailSP Mar 31 '16 at 13:45
  • 1
    I have the same annoying issue with the rearrange code shortcut not working. I posted a separate question about it, http://stackoverflow.com/questions/38715446/rearrange-code-shortcut-in-resharper-doesnt-work-in-vs2015. – flitig Aug 02 '16 at 08:32
  • 3
    Your soultion doesn't solve the problem of moving a line up/down. It moves it up/down a whole scope. – bombek Apr 29 '19 at 11:19
25

I ended up resetting my Resharper shortcuts. Then when prompted with the dialog, chose Use Visual Studio Commands for the Alt+Up & Alt+Down shortcut.

You could also set this manually in Tools > Options > Environment > Keyboard. Search for "MoveSelectedLines" and then assign Alt+Up/Down to the appropriate command.

krul
  • 2,211
  • 4
  • 30
  • 49
Mark Good
  • 4,271
  • 2
  • 31
  • 43
  • 1
    Very nice solution to reset the shortcuts. After setting the keyboard shortcuts options to none in the keyboard and menus section of the options of Resharper, the combination of Ctrl+Alt+Shift do not anymore highlight code which is good for me. I think this option is too much obstructive and I can easily do the same thing with ctrl+w which expand selection of code. But the real reason is that I use a lot of shortcuts with ctrl+shift+alt just to be sure to not be in conflict with other shortcut and having code constantly highlighted is painful. – Samuel Sep 03 '16 at 02:50
3

On my machine with Resharper 2016.1 it makes a difference on what position the cursor is located:

  • cursor located from 1st to last character on the line: the shortcuts work as described by Igal Tabachnik
  • cursor located on white spaces before 1st characters of the line the shortcuts are ignored.

Regards Bernhard

lampi
  • 83
  • 6