简体   繁体   English

在netbeans中突出显示PHP shell脚本而不扩展的语法

[英]Syntax highlighting PHP shell scripts without extension in netbeans

I have a number of shell scripts - written in PHP - within a project. 我在一个项目中有许多shell脚本 - 用PHP编写。 None of these files have a file extension and cannot have one added due to constraints caused by legacy code. 这些文件都没有文件扩展名,并且由于遗留代码导致的限制而无法添加一个文件。 Currently within Netbeans there doesn't appear to be a way to make these scripts be identified as PHP and thereforce use the syntax highlighting of other PHP scripts. 目前在Netbeans中似乎没有办法将这些脚本标识为PHP,并且强制使用其他PHP脚本的语法高亮显示。 Common methods in different editors to allow shell scripts to make use of syntax highlighting are through things like modelines in Vim ( other examples here ) but as far as i can tell there is nothing similar in Netbeans. 不同编辑器中允许shell脚本使用语法高亮的常用方法是通过像Vim中的模型( 这里的其他示例 )这样的东西,但据我所知,Netbeans中没有类似的东西。 Each file has a shebang and php tags that both identify the scripts as being php files. 每个文件都有一个shebang和php标签,它们都将脚本标识为php文件。 Does anyone know a workaround for this? 有没有人知道这个的解决方法? I'm willing to add content to the files to make this work but for a number of reasons i cannot add an extension. 我愿意为文件添加内容以使其工作,但由于多种原因我无法添加扩展名。

FWIW i'm using the PHP version of netbeans 6.9.1 with the C/C++ plugin to enable syntax highlighting of .sh files FWIW我正在使用带有C / C ++插件的PHP版netbeans 6.9.1来启用.sh文件的语法高亮

I accomplished it by right-clicking the file and selecting the "Open As..." option. 我通过右键单击文件并选择“打开为...”选项来完成它。 In the dialog window then select the "text/x-php5" option and click the "Open" button. 在对话框窗口中,然后选择“text / x-php5”选项并单击“打开”按钮。

Interestingly enough, when I go to "Tools" > "Options", "Miscellaneous" section, "Files" tab, I don't see a way to remove or change associations made for files without extensions from there. 有趣的是,当我转到“工具”>“选项”,“其他”部分,“文件”选项卡时,我没有看到一种方法来删除或更改没有扩展名的文件的关联。

After additional digging I found the file that holds the definitions. 经过额外挖掘后,我找到了包含定义的文件。 On Windows XP it can be found here: 在Windows XP上,可以在这里找到:
[%HOMEDRIVE%%HOMEPATH%]\\.netbeans\\6.9\\config\\Services\\MIMEResolver\\user-defined-mime-resolver.xml

My file looks like this: 我的文件看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.1//EN" "http://www.netbeans.org/dtds/mime-resolver-1_1.dtd">
<MIME-resolver>
    <file>
        <ext name=""/>
        <resolver mime="text/x-php5"/>
    </file>
</MIME-resolver>

Do the files have a .php extension? 这些文件的扩展名是.php吗? Syntax highlighting should be automatic if you're using the PHP version. 如果您使用的是PHP版本,则语法突出显示应该是自动的。 (By the way, the PHP version is just the core with PHP extensions installed.) (顺便说一句,PHP版本只是安装了PHP扩展的核心。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM