Tip of the Week: Moving Selected Lines in Visual Studio

Using the keyboard to move selected lines up/down.

Rahul Pulikkot Nath
Rahul Pulikkot Nath

Table of Contents

Often when coding, I need to move pieces of code up or down. It could be a group of lines of code or an entire function that I need to shift up or down. In earlier versions of Visual Studio, I had to select the lines of code, cut them from current place, move the cursor to the desired position and paste it. That's a lot of keystrokes for getting a simple thing done. In the latest versions of Visual Studio (I am currently on VS2015) we can use Alt + Up/Down to move the selection up or down. This also works for the current line without selecting it.

Defensive Coding

Hope this helps to move code around faster!

TipOW