JetBrains Rider
 
Get JetBrains Rider
Get your hands on the new features ahead of the release by joining the Early Access Program for Rider 2025.1! Learn more

Duplicate line or selection

Last modified: 23 September 2024

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 Ctrl0D 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 Ctrl0Q to invoke it, or add a keyboard shortcut to it.