55

I regularly open files of different types in Eclipse. For many types, Eclipse uses the system editor by default. I don't want this to happen. I want Eclipse to use the built-in Text Editor for unknown file types. However all I can find are options to set the default editor for a certain file type, but not for all unknown ones. Is there an option to do this?

1
  • 1
    A mechanism that solves this problem has now been implemented in Eclipse, see brunobg's answer.
    – Lii
    Commented May 30, 2018 at 8:22

4 Answers 4

44

I don't think you can do this in one swoop, however:

Windows > Preferences > General > Editors > File Association.

If you don't have a LOT of unknown file types, just type *.junk, *.punk, *.clunck and add Text Editor as the default editor.

Sadly you can't use *.* here.

1
28
+100

This issue with file associations is something that has always annoyed me with Eclipse. It is specially frustrating if you are trying to use Eclipse to edit files that don't have a file extension because then you can't even set a editor.

I searched over the Eclipse bug database and found my exact issue there. It was first reported in 2003 and up until now there is no solution for it. If you follow the long comment track over the years you will see that there is no way of setting a default editor for unknown file types. From what I gathered the problem boils down to eclipse not looking at the content of file to try to determine the type. Instead it fully depends on the file extension.

Some people have made suggestions for fixes but again nothing has come out of that. If you search the bug tracker DB you will find a lot more bugs created around this.

2
  • You can't. There are two mechanisms of selecting an editor. One is the file associations, and the other is the content (this has to be provided by modifying a plugin, it's not something exposed in the UI). However, sadly, the content selection mechanism depends on the file association to work. Commented Dec 13, 2011 at 17:59
  • This answer has now been superseded, see brunobg's answer
    – Mark Booth
    Commented Mar 25 at 17:00
21

A clean solution to this is finally implemented in Eclipse.

On the Preferences > General > Editors > File Association page, you can now define an editor selection strategy for unassociated file types.

Source: https://www.eclipse.org/eclipse/news/4.6/platform.php#text-editor-selection-strategy

3

There is an Eclipse plugin that overrides the default behavior of the platform and opens text file of unknown type in the plain text editor of Eclipse instead in an external editor.

https://github.com/eclipselabs/default-text-editor

1
  • I was not able to install that on Eclipse 3.8.1 on Ubuntu 15.04. Under Help→Install New Software, I entered the URL specified. But it said "There are no categorized items". Nor could I drag the icon into the workspace. Commented Nov 26, 2015 at 4:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.