What's the equivalent for eclipse's ALT+UP/DOWN (move line) in Visual Studio?

Visual StudioEclipseIdeKeyboard Shortcuts

Visual Studio Problem Overview


In Eclipse, selecting a line and pressing Alt + / will move the line up and down, a quick way to avoid copy&paste. Is there an equivalent in Visual Studio?

Visual Studio Solutions


Solution 1 - Visual Studio

In Visual Studio 2013 and later, this functionality is built in. ALT + UP/DOWN will move a line up or down.

If you need this functionality in VS2012 (works with VS2010 too), take a look at the MoveLine Visual Studio Extension or the Productivity Power Tools suite.

Solution 2 - Visual Studio

ReSharper's Ctrl + Shift + Alt + /// is even more powerful - when on the beginning of the line, it will move the entire line, but can also be used to move entire methods, change the order of parameters, etc.

Solution 3 - Visual Studio

For me in Visual Studio 2019 it comes default closed.

For open it:

Tools -> Options -> Keyboard then select Edit.MoveSelectedLinesUp, click "Press shortcut keys" input and press Alt + Up (or whatever you want for it). And the other one is Edit.MoveSelectedLinesDown, click "Press shortcut keys" input and press Alt + Down (or whatever you want for it).

Solution 4 - Visual Studio

This is now working out of the box with Visual Studio 2013, same way as in Eclipse.

Solution 5 - Visual Studio

In Visual Studio 2013 and later, you can move lines up and down using Alt + / Alt + . Unfortunately this will not adjust the indentation if you move between blocks, as of today only ReSharper (and all other IDE's by Jetbrains including Rider) can help you with that.

To move entire blocks of code around you can move the cursor to its head and press Ctrl + m twice fast to collapse it, and then use the command above to move it around.

Here is a neat reference to all default keyboard shortcuts in different versions of Visual Studio.

Solution 6 - Visual Studio

enter image description here

For Visual Studio 2013: Tools -> Options -> Keyboard then select Edit.MoveSelectedLinesDown, click "Press shortcut keys" input and press Alt + Down. You also have to select the scope of the shortcut to be within "Text Editor".

Solution 7 - Visual Studio

With the VSCommands extension, you have exactly that keyboard shortcut. And, by the way, a Stack OVerflow notification toolbar :)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRobertoView Question on Stackoverflow
Solution 1 - Visual StudioKevin AenmeyView Answer on Stackoverflow
Solution 2 - Visual StudioOmer RavivView Answer on Stackoverflow
Solution 3 - Visual StudioUmut SunView Answer on Stackoverflow
Solution 4 - Visual StudioDrealmerView Answer on Stackoverflow
Solution 5 - Visual StudioAndreas BergströmView Answer on Stackoverflow
Solution 6 - Visual StudioPhan-AnhView Answer on Stackoverflow
Solution 7 - Visual StudioeFlohView Answer on Stackoverflow