如何在 Eclipse 中设置默认编辑器选项卡?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3226975/
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 19:30:33  来源:igfitidea点击:

How to set default editor tab in Eclipse?

eclipsesettings

提问by guerda

I'm using the HTML editorresp. the Structured Text Editorin Eclipse. It always opens in the tab Visual/Source:

我正在使用HTML 编辑器。Eclipse 中的结构化文本编辑器。它总是在选项卡Visual/Source 中打开:

Editor tabs

编辑器选项卡

Is it possible to tell Eclipse it should always open this editor in the Sourcetab?

是否可以告诉 Eclipse 它应该始终在“源”选项卡中打开此编辑器?

回答by Mohsen

You seem to use a plugin which associates with HTML files. For example Eclipse normally loads XML files for the first time with Design tab, and once you switch to source tab, it remembers the next time to open any document associated with XML Editor in Source tab. I don't know remembering is up to Eclipse or up to the plugin associated with the file, but a quick workaround would be:

您似乎使用了与 HTML 文件相关联的插件。例如,Eclipse 通常第一次使用“设计”选项卡加载 XML 文件,一旦您切换到“源”选项卡,它就会记住下次在“源”选项卡中打开与 XML 编辑器关联的任何文档。我不知道记住取决于 Eclipse 或与文件关联的插件,但一个快速的解决方法是:

  1. to right click on the HTML file in package explorer > Open With > choose another editor (e.g. text editor). This only associates with current file. If you want to change file association for all HTMLs:
  2. goto Preferences (under menu Window) > General > Editor > File Associations and change HTML file association there.
  1. 右键单击包资源管理器中的 HTML 文件 > 打开方式 > 选择另一个编辑器(例如文本编辑器)。这仅与当前文件相关联。如果要更改所有 HTML 的文件关联:
  2. 转到首选项(在菜单窗口下)> 常规 > 编辑器 > 文件关联并在那里更改 HTML 文件关联。

回答by Kelly S. French

You didn't say what version of Eclipse you're using. My HTML / Structured Text editors didn't have the tabs the same as yours. I'm using 3.4.2.

您没有说明您使用的是哪个版本的 Eclipse。我的 HTML / 结构化文本编辑器的选项卡与您的不同。我正在使用 3.4.2。

You can extend that editor by writing your own plug-in for Eclipse. Outside of the 'create a plug-in project' stuff, start by finding the extension points for the target editor. Then your plug-in can just register as an extension and add a new property instead of writing a whole editor. The property should show up on a preference page and then your code can take care of switching the active view of the editor to the 'Source' tab based on that property.

您可以通过为 Eclipse 编写自己的插件来扩展该编辑器。在“创建插件项目”之外,首先找到目标编辑器的扩展点。然后你的插件就可以注册为一个扩展并添加一个新的属性而不是编写一个完整的编辑器。该属性应显示在首选项页面上,然后您的代码可以根据该属性将编辑器的活动视图切换到“源”选项卡。

回答by Lars

Right click the file and then "open with" and open it in another HTML or texteditor. And then map this editor as the default editor for this filetype by right clicking the document and setting the file extension.

右键单击该文件,然后“打开方式”并在另一个 HTML 或文本编辑器中打开它。然后通过右键单击文档并设置文件扩展名,将此编辑器映射为此文件类型的默认编辑器。

I always do this to get rid of the memory greedy WYSIWYG editors.

我总是这样做是为了摆脱贪婪的 WYSIWYG 编辑器。

回答by subha

In Eclipse goto Windows-->Preferences-->Type Editorschange the associated editors for File Typesafter that click on OK

在 Eclipse 中,Windows-->Preferences-->Type Editors更改关联的编辑器File Types,然后单击“确定”