Comment and uncomment code
Code | Comment With Line/Block Comment
CtrlAlt0// CtrlShift0/
With JetBrains Rider, a single keystroke is enough to comment or uncomment code.
tip
To select a logical code block, press AltShift0= one or more times; to select the current declaration, press AltShift0].
To comment or uncomment code with line comment, press CtrlAlt0/ or choose Code | Comment/Uncomment with Line Comment from the main menu
// Commented line in C# ...
If there is no selection, JetBrains Rider 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 Editor | Code Style | C# | Tabs, Indents, Alignment page of JetBrains Rider settings CtrlAlt0S.
If there is a selection, JetBrains Rider 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 AltEnter and choose Uncomment.
To comment or uncomment code with block comment, press CtrlShift0/ or choose Code | Comment/Uncomment with Block Comment from the main menu
/* Commented code block
in C# ... */
If there is no selection, JetBrains Rider 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, JetBrains Rider 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 AltEnter and choose Comment selection. The same way works for uncommenting code inside a block comment - place the caret anywhere in the block comment, press AltEnter and choose Uncomment.