Accepted answer

for single line comment you can use ctrl + / and for multiple line comment you can use ctrl + shift + / after selecting the lines you want to comment in java editor.

on mac/os x you can use + / to comment out single lines or selected blocks.


source -> remove block comment


enter image description here


the ctrl + / stopped working for me in eclipse 2021, due to conflicts of the same command. if you go into eclipse preferences generic keys and then filter by "comment" you can then click on each toggle comment to see if there are any conflicts. remove conflicts by clicking on the command and clicking unbind command, and this fixed it for me: enter image description here


you can toggle the comment on one line or selection by using the shortcut ctrl + / this adds/removes the // infront of the code line

you can block comment /* */ using the ctrl + shift + / eclipse shortcut

you can find a complete list of useful eclipse shortcuts here


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.

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


single comment ctrl + / and also multiple line comment you can select multiple line and then ctrl + /. then, to remove comment you can use ctrl + c for both single line and multiple line comment.


for a mac it is the following combination: cmd + /


ctrl + 7 to comment a selected text.


a simple way of doing is to press ctrl + shift + c, on the lines of your code.

for comment and for uncomment do same .. :)


for those who like to customize things (and screw them up), some tips:

in "preferences" - "general" - "keys", type "comment" to get a full list of comment key combination in all editors. be sure only to edit, not copy commands(because you cannot erase created ones).

for html files, look for those with scope "editing html files". the names are confusing, yes, but the description shows more or less when each and every key is used.

at last, i am only able to define block comment in html here. it works for both html code and javascript code(add at the beginning and the end, <!-- and --> if is html, and add /* and */ if is javascript). (i remember once there may be a "line comment" key (add comments for every line) but now it is not there anymore. if someone knows how to find it and tell me, i will be very grateful.) enter image description here the category must be edit. source does not work.


i found how to configure xml toggle comment! the category should be edit, too. then you can toggle comment in **xml editor(the one with "design" and "source" tabs).

enter image description here


comments in java class

  1. toggle/single line comment ( ctrl+/ ) - add/remove line comments (//…) from the current line.
  2. add block comment ( ctrl+shift+\ ) - wrap the selected lines in a block comment (/*… */).
  3. remove block comment ( ctrl+shift+/ ) - remove a block comment (/*… */) surrounding the selected lines.
  4. add javadoc comment ( alt+shift+j ) - add a javadoc comment to the active field/method/class.

comments in html/xml/config file

  1. add block comment ( ctrl+shift+/ ) - wrap the selected lines in a block comment (< !-- -->).
  2. remove block comment (ctrl+shift+\) - remove a block comment (< !-- -->) surrounding the selected lines.


ctrl + shift + c . works great on .java, .xhtml, .properties and maybe on others but i only tested these ones. can comment single or multiple lines.


in eclipse pressing ctrl + shift + l, will list all the shortcuts.


select the code you want to comment, then use ctr + / to comment and ctrl + / also to uncomment. it may not work for all types of source files, but it works great for java code.


an easier way is to press ctrl + shift + c, just like in code::blocks


  1. single line comment ctrl + /
  2. single line uncomment ctrl + /

  1. multiline comment ctrl + shift + /
  2. multiline uncomment ctrl + shift + \ (note the backslash)


ctrl + 7

does comment/uncomment in the java editor.



ctrl + shift + l which will open a list of all major shortcuts for eclipse.

  1. for single line java code comment and uncomment : ctrl + / (forward slash)

  2. for multiple line java code comment : ctrl + shift + / (forward slash) and

    multiline uncomment : ctrl + shift + \ (backslash)

  3. for single line xhtml code comment/uncomment : ctrl + shift + c

  4. for multiple line xhtml code comment : ctrl + shift + / (forward slash)

    for multiple uncomment : ctrl + shift + \ (backward slash)

for mac user it will be: instead of ctrl

Related Query

More Query from same tag