Eclipse comment/uncomment shortcut?
In Eclipse, you can use the following keyboard shortcuts to comment and uncomment lines of code:
- To comment out a single line, place the cursor on the line and press
Ctrl + /
(on Windows) orCommand + /
(on macOS). - To uncomment a single line, place the cursor on the line and press
Ctrl + /
(on Windows) orCommand + /
(on macOS) again.
To comment out multiple lines at once, select the lines and press Ctrl + /
(on Windows) or Command + /
(on macOS).
To uncomment multiple lines at once, select the lines and press Ctrl + /
(on Windows) or Command + /
(on macOS) again.
Keep in mind that the commenting and uncommenting behavior may vary depending on the programming language and the type of comments used.
For example, in Java, single-line comments start with //
and block comments start with /*
and end with */
. In this case, pressing Ctrl + /
(on Windows) or Command + /
(on macOS) will toggle between single-line comments and block comments.
You can also use the Source
menu or the context menu (right-click menu) to comment and uncomment lines of code.