Duplicate line or selection
Edit | Duplicate Line or Selection
Ctrl0D
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.
If you want to clone a line, place 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 AltShift0= one or more times; to select the current declaration, press AltShift0].
Press Ctrl0D or choose Edit | Duplicate Line or Selection from the main menu. Alternatively, you can press Ctrl0Q, 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 duplicate. If necessary, you can press Ctrl+Shift+Alt and then use arrow keys to move the duplicate to the desired position.
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.