Reputation: 2259
Is there a keystroke in visual studio similar to Eclipse's Alt + ↑/↓?
For example:
int x = 0; // Cursor is anywhere on this line.
int y = 1;
and Alt + Down were pressed, then:
int y = 1;
int x = 0; // Cursor is anywhere on this line.
Upvotes: 55
Views: 30209
Reputation: 1
Alt + Up/Down arrow in Windows. Be aware that this shortcut is not listed in the official Visual Studio Code keyboard shorcut for Windows yet (https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf)
Upvotes: 0
Reputation: 20194
VS 2013 and later:
Alt + ↑ (Edit.MoveSelectedLinesUp
)
Alt + ↓ (Edit.MoveSelectedLinesDown
)
VS 2012:
Shift+Alt+ T
(Edit.LineTranspose
)
but this only swaps between the current and the next line (move down only).
VS 2012 does not support macros but there is the Productivity Power Tools 2012 extension that adds (besides some other nice features) commands to move a line up or down with Alt + ↑ and Alt + ↓.
VS 2010 and earlier:
Line transpose works (Shift+Alt+ T) but still no move up.
You could write a macro for those commands, I think this question may help you: Visual Studio: hotkeys to move line up/down and move through recent changes
Upvotes: 103
Reputation: 17139
As an alternative solution, you could write a Visual Studio Extension to do this for you. Extensions are written in your favorite .NET language.
Refer to the MSDN article on creating Visual Studio Extensions for more information.
Upvotes: 2