2

I use Blackberry java plug-in for eclipse to write code. I have preprocessor statements in my code in the following way

     //#ifdef OS50
         //run this
     //#else
          //run this
     //#endif

Every time I do "Format" (CTRL+SHIFT+F) on this bit of code, eclipse adds a space between '//' and '#'. So if I format the above code it ends up like this

     // #ifdef OS50
         //run this
     // #else
          //run this
     // #endif

This then tells eclipse that I have comments rather than preprocessor directives. Hence I cant compile. Is there any way I could avoid eclipse doing this to my code when I format?

rfsk2010
  • 8,571
  • 4
  • 32
  • 46

1 Answers1

5

You can modify your formatter's settings not to format line comments so that no white spaces will be added:

  1. In Eclipse go to Window -> Preferences
  2. browse on the right pane to Java -> Code Style -> Formatter
  3. click Edit...
  4. Go to the Comments tab and uncheck Enable line comment formatting

Hope this helps!

BTW, if you don't want it to apply to everything you do in Eclipse, you can set it only for this project by clicking the Configure Project Specific Settings instead of the edit button in step 3.

Tamar
  • 2,016
  • 1
  • 15
  • 26