From the course: Visual Studio Tips and Techniques for Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Duplicate lines of code

Duplicate lines of code - Visual Studio Tutorial

From the course: Visual Studio Tips and Techniques for Developers

Start my 1-month free trial

Duplicate lines of code

- Here's a quick tip on a small but useful feature that first appeared in Visual Studio 2017. It provides a way to duplicate code without losing the existing content of the clipboard. You can find this command in the edit menu and it's called duplicate. And I'll be working with the control D shortcut. So the way this works is you put your cursor on a line of code. Here I'm on the end of line 22. Press control D, and you get a duplicate of that line This works if the cursor's at the beginning of the line like this, and it works wherever the cursor is. So if I put the cursor in the middle of line 25, right there, select that text, control D. When you've got text selected it duplicates the text that you selected. If you have your cursor just in the line of code, it duplicates the line. This also works with multiple line examples. So if I select these last two lines like this and do a control D, it duplicates both…

Contents