JetBrains Rider 2024.3 Help

Typing assistance

In addition to saving your time by providing smart suggestions in completion lists, JetBrains Rider provides other typing assistance features, which let you create and edit your code even faster.

Auto-Insert matching delimiters

By default, whenever you type an opening delimiter (, [, ", or ', a paired character is inserted automatically (whenever appropriate). If you change your mind and press Backspace to delete an opening delimiter, its closing pair is also deleted. If the matching closing delimiter already exists, JetBrains Rider will not add another one. The matching symbols are inserted according to your formatting preferences.

Regarding braces {}, JetBrains Rider can provide a closing brace immediately on typing the opening one, or on pressing Enter.

If necessary, you can change the default behavior. To do so, go to the Editor | General | Typing Assistance page of JetBrains Rider settings Ctrl+Alt+S and use the controls in the Braces and Parentheses section.

Correct Length/Count mistyping

JetBrains Rider prevents you from stumbling over mistyped Length/Count properties of arrays/collections. As soon as you erroneously start typing the Count property for a usage of an array, JetBrains Rider will allow you to pick it from the completion list and replace with the Length property, which you probably meant to type.

Completing mistyped Count property for array

In a similar way, it will help you call the Count property on a collection usage when you start typing the Length property by mistake.

Completing mistyped Length property for collection

The correct property will be there as soon as you accept the completion suggestion:

void Foo(int[] array, List<int> collection) { if(array.Length == collection.Count }

Create type parameter from usage in method parameters

When creating generic methods, you can easily add type parameters by typing T for a new parameter and choosing the corresponding item in the completion list

Creating type parameter from usage in method parameters

JetBrains Rider will add a new type parameter to the method declaration and bring you to a position where you can type the name of the type parameter in both its declaration and usage:

Creating type parameter from usage in method parameters

After you finish typing the name, press Enter or Tab to go on typing.

Smart behaviour of dot and semicolon

By default, when you choose a method in the completion list JetBrains Rider automatically adds parentheses and sets your caret between them in the position to start typing arguments. If you want to call the method without parameters, and chain-call another method, you can type the dot right where your caret is and JetBrains Rider will move it to the right place:

myStringBuilder.AppendLine(./*caret*/) becomes myStringBuilder.AppendLine()./*caret*/

If you just typed a complete method call, and then decide to chain-call another method, you do not have to move your caret, just type the dot right after the final semicolon:

myStringBuilder.AppendLine();./*caret*/ becomes myStringBuilder.AppendLine()./*caret*/;

When you caret is inside parentheses, you do not have to move it outside to type the final semicolon, just type it right away or after the last argument:

myStringBuilder.AppendLine("line";/*caret*/) becomes myStringBuilder.AppendLine("line");/*caret*/

Correct prefixes in verbatim string interpolation

Starting from C# 6.0, you can make the same string both interpolated and verbatim if you add the $ and @ prefixes in the correct order: $@"some string".

With JetBrains Rider, the order will be always correct — a mistakenly typed @$ will be automatically replaced with the correct $@.

Add NotNull/CanBeNull annotations

If code annotations support is enabled in your project, you can add [NotNull] and [CanBeNull] annotations, as well as generate null checks with a single keystroke:

  • When writing a method signature or member declaration, type ! or ? directly after the type name to get the item annotated with [NotNull] or [CanBeNull]:

    JetBrains Rider: typing assist for NotNull/CanBeNull annotations
  • If the symbol is already annotated with [NotNull] or [CanBeNull], you can type ? or ! correspondingly to change the existing annotation.

  • If a parameter is marked with the [NotNull] attribute, you can place the caret directly after the parameter name or parameter type and press !:

    private void Foo([NotNull] object/*!*/ arg/*!*/)

    JetBrains Rider will generate a null check for this parameter. You can configure the null-check pattern on the Code Editing | C# | Null Checking page of JetBrains Rider settings Ctrl+Alt+S.

By default, typing assist for [NotNull] or [CanBeNull] is enabled. If you want to disable it, clear the Annotate nullability... check-boxes on the Editor | General | Typing Assistance page of JetBrains Rider settings Ctrl+Alt+S.

Make comments multiline on Enter

Block comments

If you write a multiline block comment /*....*/, you can type the opening part /*, then write the first line, and the just press Enter in the end of the line — JetBrains Rider will insert the closing part */.

Additionally, JetBrains Rider will insert the asterisk * in the beginning of each line of a block comment as you press Enter. This behavior is enabled by default, but you can turn it off by clearing the Insert * on Enter after /* checkbox on the Editor | General | Typing Assistance page of JetBrains Rider settings Ctrl+Alt+S.

JetBrains Rider. Making block comments multiline on Enter

Line comments

In simple (non-XML Doc) line comments, you can press Enter in the middle of the comment text, and to avoid getting a non-compilable text on the new line, JetBrains Rider will automatically add two slashes // in front of the text. If you press Enter at the end of the comment line, you will start an empty new line as usual.

Wrap code blocks with braces and parentheses

With JetBrains Rider, you can select a code block or an expression, then type an opening { or a closing } brace to put the selection inside braces, or type an opening ( or a closing ) parenthesis to put the selection inside parentheses.

To enable or disable this behavior, use the Surround selection on typing a quote, brace or parenthesis checkbox on the Editor | General | Typing Assistance page of JetBrains Rider settings Ctrl+Alt+S.

Auto-indent new lines

When you start a new line in the editor, JetBrains Rider can automatically calculate required indent taking into account all settings that affect indentation, for example whether and how to use tabs (configurable on Editor | Code Style | [Lanugage] | Tabs, Indents, Alignment), whether to align chain method calls (configurable on Editor | Code Style | C# | Line Breaks and Wrapping), and so on.

This behavior is enabled by default and JetBrains Rider sets the caret to the expected indent position in the next line when you press Enter in the editor.

If necessary, you can disable this behavior by clearing Smart indent on Enter on the Editor | General | Typing Assistance page of JetBrains Rider settings Ctrl+Alt+S.

You can also apply this smart indentation when you press Tab at the beginning of an empty line.

To do so, assign the Tab shortcut to the Emacs Tab action.

Unindent code lines with Backspace

When you press the Backspace on an empty line or when there are only whitespaces and tabs to the left of the caret, JetBrains Rider can return the caret to the proper indent position instead of moving it back one position at a time.

JetBrains Rider: Backspace returns the caret to the proper indent position

This behavior is configurable with the Unindent on Backspace selector on the Editor | General | Typing Assistance page of JetBrains Rider settings Ctrl+Alt+S. The following options are available:

  • Disabled — returns the caret by one position at a time.

  • To nearest indent position — returns the caret to a nearest position that is a multiple of the current indent size.

  • To proper indent position (default) — returns the caret to the expected indent position according to the code structure.

Structural remove

JetBrains Rider can automatically remove remaining whitespaces and utility characters after you remove parts of different code constructs. For example, , after removing a parameter or an argument, [] after removing an attribute, or = after removing an initializer.

This happens when you press Backspace, Delete, or Ctrl+X on a code element selected with structural selection ( Ctrl+W) or with structural navigation (Tab), or if the selection is there after rearranging elements (Ctrl+Shift+Alt + Up/Down/Left/Right).

JetBrains Rider: Structural remove

To enable or disable this behavior, use the Enable structural remove checkbox on the Editor | General | Typing Assistance page of JetBrains Rider settings Ctrl+Alt+S

Last modified: 05 December 2024