Eclipse syntax highlighting preferences save and restore

I spend some time customizing the colors for syntax highlighting in Eclipse (Java, JSP, HTML, CSS, etc.) but whenever I try to export these settings via File|Export|General|Preferences and reimport them, the settings never completely get imported back. Some colors are restored and others are left unchanged, leaving me in an 'in between' state - very frustrating.

I'm using Eclipse 3.4 Ganymede, by the way.

Has anyone found a reliable way to save and restore Eclipse syntax highlighting settings?


Solution 1:

I finally figured out how to do this.

I just wanted to mention beforehand that I did try to start with a fresh Eclipse install, export the preferences to a .epf file, change just one single setting, export again, and compare the files. To my surprise, trying to import settings from a minimal .epf file did not work reliably either.

The solution that worked for me was to copy these files: {Eclipse workspace directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings/*.prefs

I tried a fresh Eclipse install on another machine and after copying those files over, all my settings were restored perfectly.

Solution 2:

The solution was to copy SOME - not all - of the files from {workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings/*.prefs into my other workspace.

In particular (per the https://stackoverflow.com/questions/96981/color-themes-for-eclipse thread):

org.eclipse.jdt.ui.prefs = Syntax Coloring    
org.eclipse.ui.editors.prefs = Text Editors

Copying other files caused things to break.

There are a couple of notes to add:

  1. I had to copy the aforementioned pair of files several times before I got the correct syntax coloring.
  2. Be sure to close the workspace, if it's open in Eclipse, before copying the files.

This worked with Eclipse Helios.

Solution 3:

I'm using JBoss Developer Studio 10 with the Eclipse Neon 4.6 engine.

All .prefs files are inside this path:

/workspace/.metadata/.plugins/org.eclipse.core.runtime/.sett‌​ings

Update: I found a similar structure on this path too:

\RedHat\JBossDev\studio\configuration\.settings

It's my IDE folder plus \configuration\.settings

I recommend search for org.eclipse.*ui*.prefs instead *.prefs to refine your result.

The principal config files are:

  • org.eclipse.jdt.ui.prefs
    • Java Syntax Color Settings
  • org.eclipse.ui.editors.prefs
    • Text Editor Settings
  • org.eclipse.cdt.ui.prefs
    • Formatter Settings
  • org.eclipse.wst.jsdt.ui.prefs
    • JavaScript Syntax Color Settings
  • org.eclipse.jst.jsp.ui.prefs
  • org.eclipse.wst.css.ui.prefs
  • org.eclipse.wst.html.ui.prefs
  • org.eclipse.wst.json.ui.prefs
  • org.eclipse.wst.dtd.ui.prefs
  • org.eclipse.wst.xml.ui.prefs
  • org.eclipse.wst.xsl.ui.prefs

If have a problematic workspace:

  1. Copy the files above
  2. Create a new workspace
  3. Copy and Replace that files in your new workspace

This will recover perfectly your custom editors color settings. For me worked very well.

Solution 4:

If you want to be a little more fine grained on what you migrate, the syntax highlighting rules are the lines starting with semanticHighlighting on workspace-indigo/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs

Doing this, I was able to migrate my syntax highlighting from Helios to Indigo

Solution 5:

Eclipse CDT stores 'Syntax coloring' in the file org.eclipse.cdt.ui.prefs

This is located for example here: C:\eclipse\workspace.metadata.plugins\org.eclipse.core.runtime.settings\

Copy and paste over the top of the one in your new eclipse instance. This worked for me when moving from 3.4 to 3.5