Keyboard shortcut to move line up/down in Visual Studio 2012?
Is there a shortcut to move a line up/down?
Visual Studio 2010 Productivity Power Tools had this feature, is it built-in on Visual Studio 2012? Is there perhaps a light extension that adds this feature?
Solution 1:
I found an extension for it: MoveLine
Compatible with VS2012. Moves a line, or group of lines, up or down in the editor using shortcut keys. Press the shortcut keys to move the line under the cursor up or down or select a block of text and press the shortcut keys to move the entire block up or down.
The default shortcut keys are as follows:
- Alt+↑ (Up Arrow) – Moves a line up
- Alt+↓ (Down Arrow) – Moves a line down
To change the shortcut keys:
- In the Visual Studio main menu go to Tools → Options
- Expand Environment
- Select Keyboard
- In the Show commands containing box type
Tools.MoveLineUp
orTools.MoveLineDown
- In the Press shortcut keys box press the new shortcut keys
- Click Assign
Solution 2:
Update Visual Studio 2013+
VS 2013+ should have this editor action built in - if you want to assign keybindings, go to:
-
Tools > Options > Keyboard
-
Search for the commands:
Edit.MoveSelectedLinesUp Edit.MoveSelectedLinesDown
-
Set the shortcut keys in "Text Editor" scope
See Also: What's the equivalent for eclipse's ALT+UP/DOWN (move line) in Visual Studio?