Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Luna Dark theme, syntax coloring resets. How to disable?

Original Question: Eclipse luna theme issue

Related Question: How to make Eclipse color settings permanent?

TL;DR Eclipse Luna 4.4, Dark theme, Win 7 64bit, some settings reset to an initial value on start. How to make them stay the way i configured them ? Examples: Java Syntax Coloring, enums are italics with the dark theme, i dont want them italics tho...

Additional Research In the workspace\.metadata\.plugins\org.eclipse.core.runtime.settings\org.eclipse.jdt.ui.prefs file there is a tag named overriddenByCSS that seems to cause this issue. It only exists if the dark theme is used. I looked into the CSS files of the dark theme but couldnt find anything related... Also removing or changing the line manually doesnt work, it gets written every start of eclipse.

Why do i ask ?

Even tho the "How to ask" mentions that a new question should be different to an allready existing one, i dont have enough reputation to comment on the original question and add details to it. So i tried in the form of an answer, but someone "thought" it was a good idea to delete my answer (that wasnt really answering, just adding more details...). So, well, lets just flood SO with duplicates then...

EDIT: I posted a bug at the eclipse bugzilla

like image 223
NooBxGockeL Avatar asked Sep 04 '14 11:09

NooBxGockeL


People also ask

How do I keep Eclipse in dark mode?

If you want to join this club, simply type "Dark" into the Quick Access box and press enter. This brings you to the correct preference page. Select Dark, press Apply and Close (and restart your IDE to fully apply the theme).

How do I turn off dark mode in Eclipse?

Just navigate to Preferences > General > Appearance. Choose "Classic" for "Theme" and hit "Apply and Close". You may have to restart eclipse.

How do I change the background color in Eclipse Luna?

Step 1: Go to Window -> Preferences in Eclipse Luna. Step 2: Go to General -> Appearance and click on Appearance. We will find the UI as given below. Step 3: To change theme, click on theme select box, and choose Dark then click on OK.


2 Answers

A few days ago a comment was added to your Eclipse bug report and I have been able to successfully workaround this issue using that advice. It's tedious, but it worked for me.

Before you get started, remember these things:

  1. Eclipse will load your preferences on startup, overwrite them with overriddenByCSS=, etc. and then restore your original settings file on exit. This means that all changes you make to org.eclipse.jdt.ui.prefs should be made while Eclipse is not running.

  2. Comparing this file while Eclipse is running to the version while Eclipse is not running will help you identify the changes you need to make to preserve your colors.

  3. Use your preferred version control system to manage these files. This will ensure that you don't lose them in the future and will help you see how Eclipse is changing your preferences when it starts. I will use Mercurial below.

Follow these steps to switch to the Dark theme while preserving control over your syntax colors:

  1. Exit Eclipse and put the core runtime settings under version control:

    cd [eclipse workspace]/.metadata/.plugins/org.eclipse.core.runtime/.settings
    hg init
    hg add .
    hg ci -m "before dark"
    
  2. Start Eclipse and switch to the Dark theme and then Exit Eclipse.

  3. Verify that only the theme changed and save the changes to a branch:

    hg diff
    hg branch dark
    hg ci -m "after dark"
    
  4. Start Eclipse again and while Eclipse is running, compare the files to what you just checked in. You will see the new overriddenByCSS value which will reference all of the values that were added by Eclipse on startup. Do a diff and keep note of what was changed and before you exit Eclipse, save these overrides.

    hg diff
    hg ci -m "eclipse overrides"
    
  5. Exit Eclipse and you will notice that the changes are gone. Restore the changes it made when it was running:

    hg revert .
    
  6. Edit org.eclipse.jdt.ui.prefs and remove the line that starts with overriddenByCSS. This will make the other overrides values stick. Save these changes.

    hg ci -m "the overrides are now mine"
    
  7. Start and Exit Eclipse and verify that Eclipse didn't make any changes to your file.

    hg diff
    
  8. Now that the overrides are yours, you are free to change them. For the example you mentioned, enums in italic, edit org.eclipse.jdt.ui.prefs and set semanticHighlighting.enum.italic=false

  9. If you ever want to go back to your default before you started this, you can switch between branches using:

    hg up -r default
    hg up -r dark
    
  10. Important note: If you change syntax color preferences using Eclipse, you'll notice that the overriddenByCSS value comes back when Eclipse is running and your preferences will disappear. Periodically monitor your preference files for changes and commit them when you like them. Revert them when you don't.

Here is what my Eclipse looks like now with all of the colors that I originally tweaked before switching to the Dark theme:

Screenshot of my Eclipse

like image 159
andykellr Avatar answered Oct 25 '22 06:10

andykellr


On Eclipse 4.6 (Ubuntu) the solution that worked for me is the following:

  • Set the Dark theme (before setting any color scheme)
  • Edit the file org.eclipse.e4.ui.css.swt.theme.prefs under .metadata/.plugins/org.eclipse.core.runtime/.settings
  • Copy the used theme id (in my case themeid=org.eclipse.e4.ui.css.theme.e4_dark)
  • Set any other theme than dark.
  • Set your desired scheme
  • Quit eclipse
  • Edit again org.eclipse.e4.ui.css.swt.theme.prefs
  • Replace the themeid with the copied value.
  • Restart eclipse.
like image 27
Shay Perlstein Avatar answered Oct 25 '22 05:10

Shay Perlstein