Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have eclipse add line comments at the indent instead at the beginning of the line?

Tags:

eclipse

When running Toggle Comment on one or more lines of code, Eclipse adds the comment (//) at the beginning of the line. Is it possible to have Eclipse add the line comment where the code is indented at instead?

This can be fixed by running Source > Format but it would be nice if it can be done automatically when Toggling Comment.

like image 299
MetaChrome Avatar asked Jul 15 '11 10:07

MetaChrome


People also ask

How do you comment multiple lines in Java?

Java Multi-line Comments Multi-line comments start with /* and ends with */ . Any text between /* and */ will be ignored by Java.

How do you comment out code in Java?

By convention, in Java, documentation comments are set inside the comment delimiters /** ... */ with one comment per class, interface, or member. The comment should appear right before the declaration of the class, interface or member and each line of the comment should begin with a "*".


1 Answers

A workaround solution is to have Eclipse do the formatting automatically: you can enable this through the "Save Action" preference.

like image 71
James Fu Avatar answered Sep 21 '22 06:09

James Fu