ReSharper Help

Commenting and Uncommenting Code

ReSharper | Edit | Comment With Line/Block Comment
Ctrl+/ / Ctrl+Shift+/
ReSharper_LineComment / ReSharper_BlockComment

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

In this topic:

Commenting and uncommenting with line comments

To comment or uncomment code with line comment, press Ctrl+/ or choose ReSharper | Edit | Comment With Line Comment in 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.

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.

Commenting and uncommenting with block comments

To comment or uncomment code with block comment, press Ctrl+Shift+/ or choose ReSharper | Edit | Comment With Block Comment in 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.

Hence the rule of thumb for block comments is to select the block you want to comment or set the caret anywhere within the block that you want to uncomment.

This feature is supported in the following languages/technologies:

C# VB.NET C++ HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see corresponding topics in the ReSharper by Language section.

See Also

Last modified: 26 August 2015