Comment and uncomment blocks of code
You can comment or uncomment the current line or selected block of source code.
Commenting feature extends to all supported file types. For the custom file types, you can define line and block comments characters, as described in the section File type associations.
Comment and uncomment lines of code
To add or remove a line comment, do one of the following:
From the main menu, select
.Press Ctrl+/.
Comment and uncomment blocks of code
To add or remove a block comment, do one of the following:
From the main menu, select
.Press Ctrl+Shift+/.
Troubleshoot
The Ctrl+Shift+/ and Ctrl+/ shortcuts currently do not not work on keyboard layouts that do not have a dedicated /
key, such as some national ones.
As a workaround, you can assign another key combination for these actions:
Press Ctrl+Alt+S to open the IDE settings and select Keymap.
In the search field, type
Comment with block comment
orComment with line comment
to locate the required action on the list.Right-click the action, select Add Keyboard Shortcut, and press the necessary key combination.
Apply the changes and close the dialog.
For more information on how to assign new key combinations to actions, refer to Add a keyboard shortcut.