Eclipse's automatic formatter changes block comments such that the Source > Remove Block Comment does not completely remove the block comment. Source > Add Block Comment adds the start and end of the clock comment to the lines of code, but after running the Formatter (Ctrl + Shift + F), it wraps the lines of code and adds an asterisk to the start of each line. When I try to remove the block comment with Source > Remove Block Comment, the start and end of the block comment is removed, but the asterisks at the beginning of each line is not removed.
How do I prevent Eclipse from adding these asterisks, or remove the asterisks when it removes the start and end of the block comment?
Example:
Code like this:
String abc="abc"; String def="def"; System.out.println(abc+def); System.exit(0);
Becomes like this after adding block comments:
/* String abc="abc"; String def="def"; System.out.println(abc+def); */ System.exit(0);
Which becomes like this after applying formatting:
/* * String abc="abc"; String def="def"; System.out.println(abc+def); */System.exit(0);
Which ends up like this after using the Remove Block Comment function:
* String abc="abc"; String def="def"; System.out.println(abc+def); System.exit(0);
Comment and uncomment blocks of codePress Ctrl+Shift+/ .
Enabling 'Folding' in the preferences dialog lets you use the '+' and '-' buttons next to the line numbers to hide comments. Do do this... Then the comments will go away!
This may be a little late in the game, but I fixed this by disabling block comment formatting.
Windows -> Preferences -> Java -> Code Style -> Formatter -> Edit -> Comments
Then uncheck Enable block comment formatting.
One other alternative solution is use of Block Selection Mode in eclipse, which is quite fast enough and still keeps your other comments formatted. You just have to press few keys to remove comments.
In windows you can toggle Block Selection Mode by ALT + SHIFT + A. Checkout the screenshot for more.
Steps to follow,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With