如何在Eclipse中使用JS或HTML编辑器打开PHP文件

问题描述:

我通常用它的默认编辑器打开一个文件。因此,在默认的PHP编辑器中打开.php文件,并将其视为PHP文件。

I normally open a file with it's default editor. Thus a .php file is opened in the default PHP editor and treated like a PHP file.

但是,我的PHP文件中的代码通常包含大量的JS或HTML。在这些情况下,使用JS或HTML编辑器打开这样的PHP文件会很不错。现在,这是一个痛苦,因为我必须点击打开方式 - >其他然后选择JS或HTML编辑器。

However, often the code in my PHP files contains a lot of JS or HTML. In these cases it would be nice to open such PHP files using a JS or HTML Editor. Right now, this is a pain since I have to click on Open With -> Other and then choose the JS or HTML Editor.

有没有办法将JS或HTML编辑器作为选项添加到打开菜单?

Is there a way to add the JS or HTML editor as an option to the Open With menu ?

尝试将PHP文件类型添加到内容类型。进入Eclipse首选项常规>内容类型

Try adding the PHP file type to Content types. Go into Eclipse Preferences General > Content Types


  1. 在内容类型中选择 JavaScript源文件

文件关联中,点击添加并添加 * .php 如下:

In the File associations click Add and add *.php like so :

然后在打开方式菜单中对于php文件,JS编辑器应该像这样开始出现:

Then in the Open With menu for php files, the JS Editor should start appearing like so :