user166560
user166560

Reputation:

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.

Upvotes: 8

Views: 11601

Answers (3)

Mickael
Mickael

Reputation: 3596

This is now natively possible fro the content-type preference page, since Eclipse Photon (2018) https://www.eclipse.org/eclipse/news/4.8/platform.php#content-type-editor-association

Upvotes: 0

jehon
jehon

Reputation: 1648

Having the same problem: if the editor is choosen by "content-type", you can not change the default editor or add a new one: the content-type screen has no option to edit that.

But, I discovered that you can configure (all) your extension(s) in your "File Associations". Eclipse will add automatically the editors (based on the Content-Type screen) AND You will then be able to add another editor and/or to change the default used one.

This is based only on a very short experience, and I didn't find any supporting documentation, but I hope it can help anybody...

Upvotes: 3

Paul Webster
Paul Webster

Reputation: 10654

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.

Upvotes: 4

Related Questions