eclipse

Eclipse: associate an editor with a content type


Can I change editor associations based on the content type rather than individual file types?

If I go to Window -> Preferences -> General -> Editors -> File Associations, I see a list of file types based on the file extension.

Clicking on "*.py" for example, the Associated Editors box lists editors that are "locked by 'Python File' content type".

I can see the message at the top that says I can "See 'Content Types' for content-type based associations", but that section of the preferences (General -> Content Types) only shows file extensions associated with the content types, not editors.

Since the hierarchy of content types is organized in a way that most files are under the "Text" content type, one of the things I'd like to do is add gvim as an external editor available for Text/* files rather than go to each file type individually and add the editor.

Thank you.


Solution

  • The only way I found to do that is by installing a plugin into your install that has the editor-to-content-type binding. In this example, I make Gedit available for the text content type:

    <extension point="org.eclipse.ui.editors">
       <editor command="gedit"
             default="false"
             id="z.ex.rcp.mail.gedit"
             name="Gedit">
          <contentTypeBinding contentTypeId="org.eclipse.core.runtime.text"/>
       </editor>
    </extension>
    

    See http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_ui_editors.html for more details.