How do I comment out a section of code?
Author: Deron Eriksson
Description: This tutorial describes how to comment out a section of code in Eclipse.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0)
(Continued from page 1)
Now we'll look at commenting out a section of code using block comments. I start by highlighting the section of code that I'd like to comment out.
I hit Control-Shift-/. This adds a block comment around the section of code.
I hit Control-Shift-\ to uncomment the block comment around the section of code.
Note that commenting and uncommenting with line comments uses the same shortcut keys, Control-/. Commenting and uncommenting with block comments uses different shortcut keys, Control-Shift-/ to comment and Control-Shift-\ to uncomment.
You can also comment and uncomment by highlighting code and right-clicking the section and going to the proper option, but it's typically much faster to use the shortcut keys.