JetBrains Rider
 
Get JetBrains Rider
You are viewing the documentation for an earlier version of JetBrains Rider.

Duplicate line or selection

Last modified: 30 September 2021

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.

JetBrains Rider helps you streamline the cloning part — with a single keystroke Ctrl+D the cloned code is inserted right after the original.

Note that when you duplicate a selection (even if the selection spans multiple lines), the duplicate is inserted right after the initial selection, without a line break.

If you want the selection to be copied as whole lines and pasted starting with a new line, use the Duplicate Entire Lines action.

This action doesn't have a keyboard shortcut by default, so you can either use Go to Action Ctrl+Q to invoke it, or add a keyboard shortcut to it.