score:284
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.
score:-1
For single line comment just use // and for multiline comments use /* your code here */
score:-1
Select the text you want to Block-comment/Block-uncomment.
To comment, Ctrl + 6
To uncomment, Ctrl + 8
score:0
Using Eclipse Mars.1 CTRL + / on Linux in Java will comment out multiple lines of code. When trying to un-comment those multiple lines, Eclipse was commenting the comments. I found that if there is a blank line in the comments it will do this. If you have 10 lines of code, a blank line, and 10 more lines of code, CTRL + / will comment it all. You'll have to remove the line or un-comment them in blocks of 10.
score:0
Eclipse Oxygen with CDT, PyDev:
Block comments under Source menu
Add Comment Block
Ctrl + 4
Add Single Comment Block
Ctrl+Shift+4
Remove Comment Block
Ctrl + 5
score:0
I have Mac ,I was also facing problem to comment multiple line in STS
I have tried
single line comment:
command+/
Multi line comment:
control+command+/
Multi line uncomment:
control+command+\
And it was success
score:1
Using Eclipe Oxygen command + Shift + c on macOSx Sierra will add/remove comments out multiple lines of code
score:2
It depends upon the version of OS - for me it works with Command + 7
score:3
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.
score:3
for java code
if you want comments single line then put double forward slash before code of single line manually or by pressing Ctrl +/
example: //System.Out.println("HELLO");
and for multi-line comments, Select code how much you want to comments and then press
Shift+CTRL+/
Now for XML code comments use Select code first and then press Shift+CTRL+/ for both single line and multi-line comments
score:3
For JAVA :
Single line comment:
// this is a single line comment
To comment: Ctrl + Shift + C
To uncomment: Press again Ctrl + Shift + C
Multiple line comment:
/* .........
.........
......... */
First, select all the lines that you want to comment/uncomment then,
To comment: Ctrl + Shift + C
To uncomment: Press again Ctrl + Shift + C
I hope, this will work for you!
score:4
In addition, you can change Eclipse shortcut in Windows -> Preferences -> General -> Keys
score:6
I have Eclipse IDE for Java Developers Version: Juno Service Release 2
and it is -
Every line prepended with //
ctrl + / for both comment and uncomment .
score:7
As other answers pointed out, the following shortcuts are defined by default (I'm referring to editing java source - shortcut bindings can be found in eclipse Window>Preferences, under 'General'/'Keys', search for 'comment'):
- to add a block comment, the shortcut (binding) is: Ctrl + Shift + /
- to remove a block comment, the shortcut (binding) is: Ctrl + Shift + \
Unfortunately, these shortcuts did not work for me (on Eclipse Java EE IDE for Web Developers, version: Juno Service Release 2).
The reason, I think, is my keyboard layout (QWERTZ keyboard layout used in Germany - see here for further information), where '/' actually has to be written via 'Shift + 7'.
I therefore had to change the shortcut bindings for comments (just did it for editing java source) in the eclipse preferences (under 'General'/'Keys') as follows:
- Change the binding of command 'Add Block Comment' (when 'Editing Java Source') from 'Ctrl + Shift + /' to 'Ctrl + Shift + 7'
- Change the binding of command 'Remove Block Comment' (when 'Editing Java Source') from 'Ctrl + Shift + \' to 'Ctrl + Shift + 8'
- Unbind the binding 'Ctrl + /' for command 'Toggle Comment' (when 'Editing Java Source'); instead of assigning a new binding, I simply unbound this shortcut, as there already was one with Ctrl+7 and one with Ctrl+Shift+C (which both work for me)
score:10
I came here looking for an answer and ended up finding it myself, thanks to the previous responses.
In my particular case, while editing PHP code on Eclipse Juno, I have found that the previous commands won't work for me. Instead of them, I should press Ctrl+ 7 (on the superior number key) to obtain the double bar comment ("//"). There's no way I can comment them with the previous mentioned key combinations.
score:29
For Eclipse Editor
For Single Line (Toggle Effect)
Comment : Ctrl+Shift+c
Uncomment: Ctrl+Shift+c
For Multiple Lines (Toggle Effect) (Select the lines you want to comment)
comment : Ctrl+Shift+c
Uncomment: Ctrl+Shift+c
It is for all html , css , jsp , java . It gives toggle effect.
score:73
There are two possibilities:
Every line prepended with //
ctrl + / to comment
ctrl + \ to uncomment
Note: on recent eclipse cdt, ctrl + / is used to toggle comments (and ctrl + \ has no more effect)
Complete block surrounded with block comments /*
ctrl + shift + / to comment
ctrl + shift + \ to remove
Source: stackoverflow.com
Related Query
- How can I customise Eclipse function comment block parsing?
- How to comment a block in Eclipse?
- How can I indent a selected block of text in Eclipse 3.5.2?
- Cannot remove block comment in Eclipse after formatting
- How to add comment block to methods in Eclipse?
- How to add a hyperlink in a comment in eclipse javadocs
- How to comment all lines contain some text in eclipse
- Eclipse - How do I create a table in the comment section of class/method?
- How to make eclipse not auto-indent a block of code
- Toggle Javadoc block comment in Eclipse
- Why eclipse jsp editor cannot parse java block comment in sperate scriptlets?
- How do I fold code for comment blocks inside method blocks in the Eclipse IDE
- Eclipse: Block comment style of ctrl+shift+/ format changed in Eclipse Version: 2018-12 (4.10.0)
- How can I configure IntelliJ IDEA to format block comments like Eclipse does?
- Perl comment block pop-up in eclipse Perl EPIC plugin
- How to prevent Eclipse formatter from inserting spaces at the beginning of line comment
- How to force team members to comment using eclipse plugin or something else
- How to prevent eclipse formatter from removing "alignment spaces" in block comments?
- How can I get block comment hotkey functionality when editing *.ftl files in Eclipse?
- how to search and replace a block in files with Eclipse or PowerGREP?
- Eclipse ctrl+/ used to // comment an entire section of Java. How do I get it back?
- Typing comment block in eclipse
- How to comment out some code fast with Eclipse JSP editor?
- eclipse how to import java types quickly in javadoc comment links?
- eclipse how to import java types quickly in javadoc comment links?
- Block comment issue with Eclipse Mars
- How to fold code block in eclipse
- How to add a comment to Gradle's eclipse task's classpath
- how to remove leading plus (+) signs from code block in Eclipse
- Installing jboss jsf 3.3 tools (no others) for Eclipse 3.7 breaks my block comment shortcut ctrl+shift+L in the jsf 2 xhtml file
More Query from same tag
- Eclipse BPMN 2.0 modeler plugin for Eclipse Che
- Bunch of Error While Importing Android Project to Eclipse, New Learner
- PostgreSQL loop with random inserts
- Doesn't get the output in Java Database Connectivity
- eclipse: Automatic branch compilation checking
- Eclipse exported Runnable Jar fails througing java.lang.UnsatisfiedLinkError exception
- Define window title when using TitleAreaDialog
- This Android SDK requires ADT version 23.0.0 or above. Current version is 22.6. Please update ADT to the latest version?
- Pivot Table for Java SWT or Swing
- integrate custom marketplace catalog eclipse
- TFS Plug-in for Eclipse (TEE) Timeout on Checkin of Multiple Items
- Is soft word wrap possible in Eclipse with the Scala plugin?
- Can i change progress bar style (likes stripes ) of eclipse progress bar?
- How preserve whitespace in code sample in phpdoc comment
- Eclipse Maven Build and Test with One Button
- Configuring FindBugs in eclipse
- How to make changes in management concole regarding WSO2 Identity Server v5.0.0
- Using Stanford CoreNLP
- Is this a valid path?
- In m2e multimodule project delinking of classpath of imported projects
- why is my @EJB not getting injected to my web service?
- get_meta_tags() connection refused
- copying or renaming an android project in eclipse
- Eclipse : Update Editor
- How to remove selected line when argument is found at the end of data?
- how to run eclipse on linux ubuntu for c programming?
- Eclipse/Java: adding a .css file to default package
- Why does JUnit take so long to launch from Eclipse?
- I can't see the graphical layout when I open an XML file
- Annoying error dialog box when eclipse output-console scrolls. What's causing it?