How to comment a block in Eclipse?

snakile picture snakile · Jan 4, 2010 · Viewed 315.7k times · Source

Does Eclipse have a hot key to comment a block? and to uncomment a block?

Answer

Jon Skeet picture Jon Skeet · Jan 4, 2010

Ctrl-/ to toggle "//" comments and Ctrl-Shift-/ to toggle "/* */" comments. At least for Java, anyway - other tooling may have different shortcuts.

Ctrl-\ will remove a block of either comment, but won't add comments.

Note: As for Eclipse CDT 4.4.2, Ctrl-Shift-/ will not uncomment a "/* */" block comment. Use Ctrl-Shift-\ in that case.

EDIT: It's Ctrl on a PC, but on a Mac the shortcuts may all be Cmd instead. I don't have a Mac myself, so can't easily check.