ReSharper 2024.3 Help

Comment and uncomment code

With ReSharper, a single keystroke is enough to comment or uncomment code.

Comment and uncomment with line comments

To comment or uncomment code with line comment, press Control+/ or choose ReSharper | Edit | Comment with Line Comment from the main menu

// Commented line in C# ...

If there is no selection, ReSharper will comment the current line, or uncomment if the line is commented, and moves the caret to the next line.

According to the Don't indent comments started at first column option, the comment will be added with or without the indent. You can configure this option for different languages separately, for example, for C# it is on the Code Editing | C# | Formatting Style | Tabs, Indents, Alignment page of ReSharper options Alt+R, O.

If there is a selection, ReSharper will comment or uncomment all the lines that the selection spans. Even if a line is partly selected, the comment mark is inserted in the beginning of this line.

An alternative way to uncomment any line comment is to place the caret at this line, press Alt+Enter and choose Uncomment.

Comment and uncomment with block comments

To comment or uncomment code with block comment, press Control+Shift+/ or choose ReSharper | Edit | Comment with Block Comment from the main menu

/* Commented code block in C# ... */

If there is no selection, ReSharper will create an empty block comment at the first whitespace that follows the current caret position.

If the caret is within a block comment, the block is uncommented.

If there is a selection, ReSharper will add block comment marks in the beginning and in the end of the selection. The caret is moved to the end of the block comment.

An alternative way to comment any block of code is to select it, press Alt+Enter and choose Comment selection. The same way works for uncommenting code inside a block comment - place the caret anywhere in the block comment, press Alt+Enter and choose Uncomment.

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 available in Protobuf

Feature is not 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 Languages and frameworks section.

Last modified: 25 September 2024