使 Eclipse 以 PHP 的形式查看不同的文件扩展名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1959606/
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
Making Eclipse view different file extensions as PHP
提问by Nick Heiner
I have several file extensions, like .module
, that I would like to be understood by Eclipse to be PHP - so I get the same syntax highlighting, code completion, etc features as I would if I were editing a .php
file. How can I do this?
我有几个文件扩展名,例如.module
,我希望 Eclipse 将它们理解为 PHP - 所以我获得了与编辑.php
文件相同的语法突出显示、代码完成等功能。我怎样才能做到这一点?
I went to Window >> Preferences >> General >> File Associationsand added *.module
to the file types list. When I click on *.module
, it now says the associated editors are the PHP Editor and the Text editor.
我转到窗口>>首选项>>常规>>文件关联并添加*.module
到文件类型列表中。当我单击 时*.module
,它现在显示关联的编辑器是 PHP 编辑器和文本编辑器。
However, when I open the *.module
file to edit it, it gives me an error message:
但是,当我打开*.module
文件进行编辑时,它给了我一条错误消息:
Unsupported content type in editor. To associate a file extension with a supported content type, please see the Content Types Preferences Page.
编辑器中不支持的内容类型。要将文件扩展名与支持的内容类型相关联,请参阅内容类型首选项页面。
What am I doing wrong?
我究竟做错了什么?
fixed:restarted Eclipse, and now it works.
修复:重新启动 Eclipse,现在它可以工作了。
回答by cowgod
Head to Window -> Preferences. Drill down to General -> Editors -> File Associations. From here you can add your extensions (e.g., *.module) and associate them with your preferred PHP editor.
前往Window -> Preferences。深入到General -> Editors -> File Associations。从这里您可以添加您的扩展名(例如,*.module)并将它们与您喜欢的 PHP 编辑器相关联。
Then restart Eclipse for the change to take effect.
然后重新启动 Eclipse 以使更改生效。
回答by plhn
FYI.
供参考。
window > preference > general > content types.
Expand '?Text' and you will find 'PHP Content Type'. Select that.
Then click 'Add' and insert your own extension.
窗口 > 首选项 > 常规 > 内容类型。
展开“?Text”,您将找到“PHP 内容类型”。选择那个。
然后单击“添加”并插入您自己的扩展名。
回答by Shaun Montgomery
Something extra to be aware of.
需要注意的一些额外事项。
I had the same problem, even after installing PDT. Turns out that there was an entry in General=>Content Types=>Text for *.php. Note that this not under General=>Content Types=>Text=>PHP Content Type, which is placed there by PDT. Removing the one under Text fixed the problem for me.
即使在安装 PDT 之后,我也遇到了同样的问题。原来在 General=>Content Types=>Text 中有一个条目用于 *.php。请注意,这不在 General=>Content Types=>Text=>PHP Content Type 下,它由 PDT 放置在那里。删除 Text 下的那个为我解决了这个问题。