javaeclipseeclipse-formatter

How to prevent Eclipse formatter from inserting spaces at the beginning of line comment


The Eclipse formatter inserts a space before the content of line comments like this:

//foo bar

turns into

// foo bar

How can I stop this? No option I found in eclipse seems to disable this behavior. (apart from completely disabling line comment formatting which I don't want to do because line wrapping is still helpful)


Solution

  • A distinct non answer: don't fight tooling.

    I have never seen comments without that initial space, so my conclusion is: eclipse is not offering an option for this case because "nobody" needs that feature.

    Especially when writing code, you have to balance your personal "preference" versus "what everyone does". Meanung: when 99 of 100 coders find your style strange and surprising, then it might be better for you to do what the other 99 people do. Or, as they say: when you are in Rome, do as the Romans do!