Duplicate line or selection

Last modified: 07 April 2022

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+Shift+A to invoke it, or add a keyboard shortcut to it.