Eclipse Global Preferences
Join the DZone community and get the full member experience.Join For Free
eclipse is good, but like any other tool: it gets better after i have it customized for my special needs. eclipse stores a lot of settings in the workspace, see my article about copy my workspace settings . but is there a way to apply some settings to every workspace? at least to the new ones? because importing/exporting the settings can get really tedious as i have many workspace. and indeed, there are global settings in eclipse. and i want to have them changed…
warning: changing eclipse global preferences might break an eclipse installation. so better have a backup of the changed files at hand!
question: where are the global preferences stored? the first thing to check is the eclipse\configuration\.settings folder: here some plugins store their global preferences. for example: the recent workspace settings are in org.eclipse.ui.ide.prefs.
#fri apr 06 16:46:14 cest 2012 recent_workspaces_protocol=3 max_recent_workspaces=10 show_workspace_selection_dialog=true eclipse.preferences.version=1 recent_workspaces=c\:\\tmp\\wsp_test\nc\:\\tmp\\wsp_10.2
but what about all the other settings? looking at the codewarrior installation, inside the eclipse folder, i find the cwide.ini file.
this file defines the eclipse startup options for launching the ide (cwide.exe for codewarrior). the interesting part is this line:
this tells eclipse to use the cwide.properties as a default configuration file. if i inspect that file, it has the following content:
org.eclipse.debug.ui/org.eclipse.debug.ui.switch_perspective_on_suspend=always org.eclipse.debug.ui/org.eclipse.debug.ui.switch_to_perspective=always org.eclipse.ui.editors/spellingengine=org.eclipse.cdt.internal.ui.text.spelling.cspellingengine
ok, that gives me an idea how settings could look like. but the question is: how to know the settings and syntax? what works (most of the time) is following approach:
- launch eclipse with a new workspace
- export the settings using file > export > general > preferences to a file
- change the setting in window > preferences
- export the settings using file > export > general > preferences to a different file
- compare/inspect the exported information and find the settings
- apply the settings to the cwide.properties file, without the /instance/ part
- restart the ide and check if it works with a new workspace
the last check is necessary as not all settings might work that way, see this forum post .
this is maybe best illustrated with an example. i have configured my workspace to use 2 for tab width and to insert spaces for tabs:
if i compare the two exported .epf files, this gives me:
that means the two following lines are configuring what i have changed:
for the cwide.properties file i need to cut off the /instance/ part, so i have this added to the cwide.properties :
# set tab width to 2 org.eclipse.ui.editors/tabwidth=2 # using spaces for tabs org.eclipse.ui.editors/spacesfortabs=true
note: preferences are applied in following order: global preferences, then local (workspace) preferences
this does not overwrite an existing setting of my workspace. as i can see from above diff, my initial workspace settings do not have any settings for tabwidth and spacesfortabs. creating a new workspace use and apply my new settings. but once i have the them, they will not be overwritten with new global ones. which makes sense: the local settings are winning.
note: post a comment if you know an elegant way how to enforce/overwrite workspace settings with global ones.
Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.