JetBrains Rider 2021.3 Help

Cut, copy, paste

Apart from standard cut, copy, and paste operations, JetBrains Rider lets you copy file paths, symbol references, and so on. When pasting, you can optionally choose items from clipboard history and automatically apply formatting rules.

Cut and copy code to the clipboard

Cut line or selection

  1. Set the caret anywhere in the line to cut the whole line, or select a block that you want to cut.

  2. Press Ctrl+X or choose Edit | Cut from the main menu .

Copy line or selection

  1. Set the caret anywhere in the line to copy the whole line, or make a selection to copy.

  2. Press Ctrl+C or choose Edit | Copy from the main menu .

When cutting and copying text from the editor, by default JetBrains Rider puts it as rich text to the clipboard, keeping the highlighting colors and font. But you can also copy it as plain text.

Copy selection as plain text

  • If you want to always copy editor selection as plain text, choose the corresponding option under Rich-Text Copy on the Editor | Code Editing page of the IDE settings Ctrl+Alt+S.

  • If you want to have rich-text copy by default, you can make a single plain-text copy by right-clicking the selection and choosing Copy / Paste Special | Copy as Plain Text from the context menu.

Copy code reference information

When you need to log or share the context of the current location, such as the name of the symbol under the caret or its XML-documentation ID, the path to the file or the VCS path, you can press Ctrl+Alt+Shift+C and copy the desired reference from a popup:

JetBrains Rider: Copying code reference to clipboard

Copy symbol name

When you invoke this command on any symbol (declaration or usage), it automatically copies its fully-qualified name to the clipboard. If you need the name or namespace only, you can choose those in the popup.

You may need the fully-qualified name of a symbol in different situations, for example, when you use reflection.

Copy XML-Doc ID

When you invoke this command within a namespace, type, or a member, you can choose XML-Doc ID from the popup to copy the XML-documentation ID of the enclosing entity. You can use this ID when referencing this entity in XML-doc comments of other symbols. For more information about the ID format, see Processing the XML File (C# Programming Guide).

For example, for the method MyMethod declared as

namespace MyNamespace { class MyClass { void MyMethod(){} } }

the XML-doc ID will be M:MyNamespace.MyClass.MyMethod

Copy paths

There are also several ways to copy the path to the current file and line in any format:

  • Press Ctrl+Shift+C to copy the absolute path to the current file.

  • Choose Edit | Copy Path/Reference from the main menu. In the popup that opens, choose what part of the path you want to copy — filename, absolute, or relative path.

    JetBrains Rider: Copy Path / Reference popup

Copy GitHub repository URL

If the current file is in a Git repository with GitHub as remote, you can choose to copy the GitHub URl to the file from the popup. For example:

Copy editor tooltip contents

JetBrains Rider editor displays additional information for code elements in tooltips. For example, error description Ctrl+F1, which appears on highlighted code issues if the design-time code inspection is enabled for the current file, or Quick DocumentationCtrl+Q that shows full symbol specification (and its documentation if available).

JetBrains Rider: Quick documentation popup

You can copy the full contents of the tooltip by Alt-clicking it (Ctrl+Alt-clicking it if you are on Linux).

Paste from the clipboard

When pasting C# and VB.NET code from the clipboard, JetBrains Rider behaves depending on the state of the Auto-format on paste selector on the Editor | General | Typing Assistance page of JetBrains Rider settings Ctrl+Alt+S.

This selector lets you configure whether to apply code formatting rules for pasted code. By default, JetBrains Rider only applies indentation settings when you paste code, which is a convenient option if you do not want to follow formatting rules very strictly.

Paste the last clipboard entry

  1. Set the caret to the place where you want to paste the last clipboard entry or select a code block that you want to replace with the clipboard entry.

  2. Press Ctrl+V or choose Edit | Paste | Paste from the main menu .

Alternatively to pasting with the selected formatting preference, you can insert the clipboard entry with its original formatting.

Paste the last clipboard entry with original formatting

  1. Set the caret to the place where you want to paste the last clipboard entry or select a code block that you want to replace with the clipboard entry.

  2. Press Ctrl+Alt+Shift+V or choose Edit | Paste | Paste as Plain Text from the main menu .

You can also access your clipboard history and quickly paste any of the recent items copied to the clipboard. JetBrains Rider starts recording copied items to its clipboard history as soon as you start it and clears the history when you close it.

Paste specific entry from the clipboard history

  1. Set the caret to the place where you want to paste the last clipboard entry or select a code block that you want to replace with the clipboard entry.

  2. Press Ctrl+Shift+V or choose Edit | Paste | Paste from History... from the main menu .

  3. In the Choose Content to Paste dialog, you can choose one of the recent clipboard entries and preview it.

  4. Click Paste or Pate without formatting to paste the desired entry in a corresponding way. Alternatively, press a mnemonic key displayed next to the desired entry to quickly insert it.

    JetBrains Rider: Choose Content to Paste dialog

If you want to clone a line or a selected block right under it, you don't have to copy and paste it. Instead, you can use a dedicated action for that.

Duplicate the current line or selection

  1. 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+[.

  2. 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.

  3. 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.

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

Smart paste

JetBrains Rider helps you automatically escape illegal characters in text that you copy/paste around your code.

If the pasted text contains characters that are illegal for the current context JetBrains Rider displays a popup that suggests escaping all illegal characters. To accept this suggestion, press Alt+Enter or press Esc to reject it.

For example, when you paste a piece of text that contains double quotes into a string literal, JetBrains Rider suggests to automatically escape all the quotes:

JetBrains Rider automatically escapes double quotes in pasted string.

Another example is pasting a piece of code with generics into an XML doc tag: JetBrains Rider will replace angle brackets with corresponding escape sequences.

JetBrains Rider automatically escapes angle brackets in pasted string.

When pasting text inside comments, JetBrains Rider will escape */ when pasted into multiline comments and replace newlines with indent and // or /// when pasted into line or XML-doc comments.

Last modified: 07 December 2021