Edit | Duplicate Line or Selection
Ctrl+D
One of the ways of creating a code element similar to an existing one (for example, a new method overload or a new auto-implemented property) is cloning the existing element with copy-paste and then editing the clone.
Visual Studio Community For Mac
JetBrains Rider helps you streamline the cloning part — with a single keystroke Ctrl+D the cloned code is inserted right after the original.
Use the Visual Studio debugger to quickly find and fix bugs across languages. The Visual Studio for Mac debugger lets you step inside your code by setting Breakpoints, Step Over statements, Step Into and Out of functions, and inspect the current state of the code stack through powerful visualizations. Restrict Blank Line Cut or Copy while coding in Visual Studio Abhijit Jana 5 years ago Visual Studio Here is another handy and quick tip that can you help you to avoid accidental copying blank line of code.
Quickly duplicate the current line or selection
Microsoft Visual Studio Mac
- If you want to clone a line, set the caret at this line line. To clone an arbitrary piece of code, select it in the editor.
To select a logical code block, press Ctrl+W one or more times; to select the current declaration, press Ctrl+Alt+Shift+[.
Press Ctrl+D or choose Edit | Duplicate Line or Selection from the main menu. Alternatively, you can press Ctrl+Shift+A, start typing the command name in the popup, and then choose it there.
The duplicated line or multi-line selection is inserted below the original line or selection; the duplicated inline selection is inserted to the right of the original.
If you have duplicated a selection, the selection stays at the clone. If necessary, you can press Ctrl+Shift+Alt and then use arrow keys to move the clone to the desired position.