IntelliJ IDEA 13.1.0 Web Help

In this section:

Basics

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 Creating and Registering File Types.

Configuring commenting behavior

It is possible to force IntelliJ IDEA to place Java comments strictly at the left margin. To do that, in the Settings dialog, open Code Style | Java, and click Code Generation tab.

In the section Comment Code select the required check boxes:

ij_comment_code

If the check boxes are cleared, the comments characters are placed at the current caret position.

Commenting or uncommenting lines of code

To comment or uncomment the current line of code, do one of the following
  • On the main menu, choose Code | Comment with Line Comment.
  • Press Ctrl+Slash or Ctrl+NumPad /Ctrl+Slash or Ctrl+NumPad /Ctrl+Slash or Ctrl+NumPad /Ctrl+Slash or Ctrl+NumPad /Alt+SemicolonCtrl+Slash or Ctrl+NumPad /Ctrl+Slash, Ctrl+NumPad / or Ctrl+ColonCtrl+Slash, Ctrl+NumPad / or Ctrl+Shift+CCtrl+Slash or Ctrl+NumPad /Command Slash or Command NumPad /Command Slash or Command NumPad /Command Slash or Command NumPad /.

    comment1.png

Commenting or uncommenting blocks of code

To add or remove a block comment, do one of the following
  • On the main menu, choose Code | Comment with Block Comment.
  • Press Ctrl+Shift+Slash or Ctrl+Shift+NumPad /Ctrl+Shift+Slash or Ctrl+Shift+NumPad /Ctrl+Shift+Slash or Ctrl+Shift+NumPad /Ctrl+Shift+Slash or Ctrl+Shift+NumPad /Ctrl+Shift+Slash or Ctrl+Shift+NumPad /Ctrl+Shift+Slash or Ctrl+Shift+NumPad /Ctrl+Shift+Slash, Ctrl+Shift+NumPad / or Ctrl+Shift+ColonCtrl+Shift+Slash or Ctrl+Shift+NumPad /Ctrl+Shift+SlashAlt Command Slash, Alt Command NumPad /, Control Shift Slash, Control Shift NumPad /, Shift Command Slash or Shift Command NumPad /Control Shift Slash, Control Shift NumPad /, Shift Command Slash or Shift Command NumPad /Control Shift Slash.

    comment2.png

See Also

Procedures:

Reference:

Web Resources: