Visual Studio Tip #7: Whole line editing


OK here is a quick simple one. How do I move or edit entire lines of code?

#1 Just don’t select anything.

If you don’t have anything selected in your code window then the commands for copy, cut and paste work as if the entire line of code was selected.

So if you need to quickly duplicate a line, don’t bother trying to get a whole line selected. Just put the cursor on the line then type Ctrl+C, Ctrl+V and you’ll see the new line pasted below the old line.

#2 Just move the line. Put your cursor on the line in question and use Alt+UpArrow or Alt+DownArrow to move the entire line up or down in your file.

This post is part of a series of Visual Studio tips. The first post in the series contains the whole list.

(next tip: Adding existing files with Show All Files)

Comments (5)

  1. Justin says:

    Don't forget about Ctrl+D to just straight up duplicate the whole line.

  2. BenWilli says:

    @Justin Are you sure that's not a Resharper hotkey?

  3. Andrei Rinea says:

    Ctrl-D is ReSharper-only

  4. Chris Marisic says:

    I'm a big fan of shift+delete for cutting entire lines, especially for killing white space blocks etc.

  5. Giulio Vian says:

    Alt+Up or Down, just like in Office!

Skip to main content