ReSharper 2023.3 Help

Highlighting of matching code elements

When you move through the code using the keyboard, ReSharper helps you quickly understand code structure by highlighting code elements that match the one where your caret is

Matching delimiters

ReSharper highlights the opening or closing delimiter ((), [], {}, and <>) when you place the caret at its pair. Any opening parenthesis, bracket, brace or quote (altogether called "delimiters") can be highlighted with color or outline whenever you place the caret at the corresponding closing delimiter, and vice versa.

If necessary, you can disable highlighting of matching delimiters or configure their behavior:

  • When to highlight matching delimiters: when the caret is directly to the left or to the right of one of the delimiters or only when it is at the outer side.

  • Whether to highlight matching delimiters with a configurable background color

    ReSharper: Highlighting the matching delimiter with color

    or with an outline border:

    ReSharper: Highlighting the matching delimiter with an outline border

To define how ReSharper highlights matching delimiters, use the Highlight matching delimiters preference on the Environment | Editor | Appearance page of ReSharper options (Alt+R, O) .

To specify the color to highlight matching delimiters, go to Visual Studio options (Tools | Options), open the Environment | Fonts and Colors page, and select the desired colors for the ReSharper Brace Outline and/or ReSharper Matched Brace items.

Matching control flow keywords

ReSharper highlights matching control flow keywords such as return, yield, and throw together with the corresponding return type; if and else that are parts of the same condition; case and default together with the corresponding switch; break and continue with the corresponding for, foreach, or while; as well as related async and await keywords in the same method.

In the example below, ReSharper highlights all places where the method can return when the caret is at one of the return or throw statements.

ReSharper highlights function exits

You can configure some of these highlightings with the Highlight context exits and Highlight related async/await keywords options on the Code Inspection | Settings page of ReSharper options (Alt+R, O) .

Matching logical and conditional operators

ReSharper highlights matching logical and conditional operators (|, ||, &, &&, as well as ? and ? pairs) that work together in a complex expressions when your caret is at one of such operators.

In the example below, %product helps understand that the highlighted operators will be evaluated together, while the value1 > 1 || value2 >= 2 && condition1 part will be evaluated before, and the || value6 %lt; value7 || condition2 part will be evaluated after, according to the operator precedence.

ReSharper: Highlighting of matching logical operators

You can disable this highlighting by clearing the Highlight condition elements checkbox on the Code Inspection | Settings page of ReSharper options (Alt+R, O) .

This feature is supported in the following languages and technologies:

Language: C#

Language: VB.NET

Language: C++

Language: HTML

Language: ASP.NET

Language: Razor

Language: JavaScript

Language: TypeScript

Language: CSS

Language: XML

Language: XAML

Language: Resx

Language: Build Scripts

Language: Protobuf

Language: JSON

Feature is available in C#

Feature is available in Visual Basic

Feature is available in C++

Feature is available in HTML

Feature is available in ASP.NET

Feature is available in Razor

Feature is available in JavaScript

Feature is available in TypeScript

Feature is available in CSS

Feature is available in XML

Feature is available in XAML

Feature is available in Resource files

Feature is available in build script files

Feature is not available in Protobuf

Feature is available in JSON

The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the ReSharper by language section.

Last modified: 18 March 2024