36

I love the color themes (thanks!), but one seriously nagging issue is that the code that is #ifdef'd out, is impossible to read (and annoyingly bright). If I highlight those lines, I can read it, but I'd really really rather not see it at all. Seems to be a similar issue as the one for tool-tips, but I am hoping that there is a setting somewhere to turn off the syntax highlighting for inactive code. I have looked and not found it, but that doesn't necessarily mean it doesn't exist. I am an optimist (in this regard anyway).

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Billy Pilgrim
  • 1,842
  • 3
  • 22
  • 32

5 Answers5

68

You can disable #ifdef highlighting entirely by going to:

Window -> Preferences -> C/C++ -> Editor and unchecking the box "Highlight inactive code".

Also, you can change the #ifdef highlighting color by going to that same screen and changing the "Inactive code highlight" color (under "Appearance color options" heading) to a color that works better for you.

MonkeyWithDarts
  • 755
  • 1
  • 7
  • 17
Thuener
  • 1,359
  • 1
  • 13
  • 13
  • This solution works for me on Windows using Visual Studio as compiler, probably because Eclipse thinks the symbols are undefined and so the code is all inactive. Not sure how to solve the situation where the symbols are defined and active, as here:http://stackoverflow.com/questions/19039874/can-i-have-eclipse-highlight-an-ifdef-block-of-code-regardless-of-whether-the-s?lq=1 – MonkeyWithDarts Nov 05 '13 at 20:07
  • 1
    3 years and these annoyances are still the same! – dashesy Jan 16 '16 at 00:46
  • the year is 2022 and this is still an issue. arg. – Trevor Boyd Smith Mar 10 '22 at 20:21
23

Window -> Preferences -> C/C++ -> Editor -> Appearance code options -> Inactive code highlight Choose another color. I prefer grey.

I also recommend to change occurrences background: General -> Editors-> Text Editors -> Annotations -> C/C++ Occurrences

Sergei Krivonos
  • 4,217
  • 3
  • 39
  • 54
7

I found this: https://github.com/eclipse-color-theme/eclipse-color-theme/issues/35

"Preferences -> C/C++ -> Editor, “Highlight inactive code” checked, Appearance color options: Inactive code highlight."

This turns off the highlighting for the inactive parts of the code, making them readable again. I haven't found a way yet to change the highlighting color.

John
  • 71
  • 1
3

Well, I found a partial answer:

Preferences -> C/C++ -> Editor -> syntax highlighting -> preprocessor -> directives changed the foreground color to black.

Preferences -> C/C++ -> Editor -> syntax highlighting -> preprocessor -> others changed foreground color to black

Preferences -> C/C++ -> Editor -> syntax highlighting -> code -> others changed foreground color to black.

At least now I can see it. Anyone know how/where to change the background color for those blocks?

Thanks!

Billy Pilgrim
  • 1,842
  • 3
  • 22
  • 32
2

I was looking also for write occurance background. I'll recommend for everybody to change also "Test as" to "Dashed Box" in: Preferences -> General -> Editors -> Text Editors -> Annotations -> C/C+ Write Occurrences

Paweł Iwaneczko
  • 853
  • 1
  • 10
  • 13