Commenting out code

You can comment out one or more lines of code in any source editor view. The leading characters // are added to the beginning of each line when commenting one or more lines of code. You can also block comment multiple lines of code using the characters /* */.

Tip: The characters /* */ on lines that already are already commented out are not affected when you comment and uncomment code as described above.

Commenting out code menu choices

To toggle // comments on code:

  1. In the source editor, select the line(s) of code that you want to comment out. If no lines are selected comments will be added (or removed) at the current cursor position.
  2. Right-click and select Source > Toggle Comment. (CTRL+/)

To block comment /* */ code:

  1. In the source editor, select multiple line(s) of code to comment out.
  2. To comment out multiple code lines right-click and select Source > Add Block Comment. (CTRL+SHIFT+/)
  3. To uncomment multiple code lines right-click and select Source > Remove Block Comment. (CTRL+SHIFT+\)

Related concepts
Code entry

Related tasks
Customizing source editor
Working with Content Assist

Related reference
Source editor preferences


IBM Copyright Statement