5
votes

I have a number of shell scripts - written in PHP - within a project. 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. 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. Each file has a shebang and php tags that both identify the scripts as being php files. 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

2

2 Answers

11
votes

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.

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:
[%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>
-1
votes

Do the files have a .php extension? Syntax highlighting should be automatic if you're using the PHP version. (By the way, the PHP version is just the core with PHP extensions installed.)