如何使编辑器成为 Eclipse 中所有未知文件的默认编辑器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7007199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 20:24:58  来源:igfitidea点击:

How do I make an editor the default editor for all unknown files in Eclipse?

eclipse

提问by Thomas L?tzer

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?

我经常在 Eclipse 中打开不同类型的文件。对于许多类型,Eclipse 默认使用系统编辑器。我不希望这种情况发生。我希望 Eclipse 对未知文件类型使用内置的文本编辑器。但是,我所能找到的只是为特定文件类型设置默认编辑器的选项,但不能为所有未知文件类型设置默认编辑器。有没有办法做到这一点?

回答by Ali

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

但是,我不认为您可以一口气做到这一点:

Windows > Preferences > General > Editors > File Association.

Windows > 首选项 > 常规 > 编辑器 > 文件关联。

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

如果您没有很多未知的文件类型,只需键入*.junk*.punk*.clunck然后将文本编辑器添加为默认编辑器。

Sadly you can't use *.* here.

遗憾的是你不能在这里使用 *.* 。

回答by jkysam

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.

文件关联的这个问题一直让我对 Eclipse 感到恼火。如果您尝试使用 Eclipse 编辑没有文件扩展名的文件,那会特别令人沮丧,因为这样您甚至无法设置编辑器。

I searched over the Eclipse bug database and found my exact issuethere. 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.

我搜索了 Eclipse 错误数据库,并在那里找到了我的确切问题。它于 2003 年首次报道,直到现在还没有解决方案。如果您多年来一直关注长评论,您会发现无法为未知文件类型设置默认编辑器。从我收集到的问题归结为 eclipse 没有查看文件的内容来尝试确定类型。相反,它完全取决于文件扩展名。

Some people have made suggestionsfor 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.

有些人提出了修复建议,但同样没有任何结果。如果您搜索错误跟踪器数据库,您会发现更多围绕此创建的错误。

回答by brunobg

A clean solution to this is finally implemented in Eclipse.

最终在 Eclipse 中实现了一个干净的解决方案。

On the Preferences > General > Editors > File Associationpage, 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

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

回答by Kaloyan Raev

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.

有一个 Eclipse 插件可以覆盖平台的默认行为,并在 Eclipse 的纯文本编辑器中而不是在外部编辑器中打开未知类型的文本文件。

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

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