11

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.

Jake Wilson
  • 88,616
  • 93
  • 252
  • 370
MetaChrome
  • 3,210
  • 6
  • 31
  • 48
  • Instead of pressing `ctrl + /` manually type `//` on the new line. – Nishant Jul 15 '11 at 10:10
  • 4
    That's a horrible answer if you have 50 lines of code to comment. I'd like to see a proper answer to this question too. – Jake Wilson Sep 09 '11 at 21:07
  • It was [already reported](http://stackoverflow.com/questions/4225951/eclipse-toggle-comment-indented) and the bottomline is that Eclipse team does not want to have it done: https://bugs.eclipse.org/bugs/show_bug.cgi?id=321092 – MichalR Oct 14 '11 at 19:39
  • 3
    The unwillingness of the Eclipse team to make this happen is so frustrating. – arxpoetica Mar 01 '12 at 23:43
  • 2
    another arrogant "we know better" dev team after gnome and chrome devs... I am so sick of this.... – Pawel Barcik Jan 20 '13 at 20:23

1 Answers1

2

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

James Fu
  • 498
  • 2
  • 4
  • 12