Eclipse syntax highlighting preferences save and restore

后端 未结 10 1896
甜味超标
甜味超标 2020-12-22 15:20

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|

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-22 16:03

    Once Michael Bosworth's answer helped me to some extend and I voted up. But now I see some obligation to answer it myself, because copying these two files are not enough. Let me explain why.

    • First, these files contains lines irrevelente to syntax coloring.
    • Second, syntax coloring for other editors are located elsewhere, for example, those of XML files are in

      org.eclipse.wst.xml.ui.prefs

    and those of HTML files:

        org.eclipse.wst.html.ui.prefs
    

    JSP pages?

        org.eclipse.jst.jsp.ui.prefs
    

    , etc.

    • Third, when we change font colors, usually we change background colors, line highlighting colors, etc. to get a clearer view of codes. This involves more files.

    If we search *.pref files in path

    /workspace/.metadata/.plugins
    

    we can find all preferences files where we can locate all lines of coloring settings. But by copy-pasting all these files to another workspace can also trigger problems, for they are not exclusively syntax-coloring-related. Moreover, when we are switching between two versions of Eclipse, unexpected problems may arise.

    So, the safest way is:

    • Create a new workspace if you don't have one.
    • Open all *.pref files we find in the workspace one by one,
    • Copy those lines containing color codes,
    • Find the same file in your new workspace,
    • Replace the color part by existing one. Or, set the colors in Eclipse, by assuming the corresponding options according to properties' name. All color codes are RGB based.

    EDIT: (2017.02.24)

    Eclipse Mars has a plugin Oomph, which can record your preference settings to provide seamless transmission of your preferences. When you activate it, every time you change a value, it prompts to ask you if you want to record it in Oomph, providing you the exact line in the corresponding file where your new value is stored. So, when you install Oomph, you can:

    1. Change the settings of your font face, font size, background color, etc.
    2. In the prompt windows of Oomph, take note of the location of your new settings. (Because if you tell Oomph to remember your settings, it will not prompt never again, so you may only see this windows once.)

提交回复
热议问题