How to add a custom file extension that has a dot (blade.php) in NetBeans?

后端 未结 4 1891
旧时难觅i
旧时难觅i 2021-01-01 19:24

I need to assign a custom extension to be recognized as a twig file in netbeans (\'blade.php\' as \'twig\' file and give me syntax highlighting and code completion appropria

4条回答
  •  醉梦人生
    2021-01-01 19:47

    A lot of people are developing on other systems, as I am on Centos 7, so this workaround almost worked.

    For CentOS, and probably other systems as well, follow these steps, almost the same as above for Windows:

    • Open Netbeans. Go to Tools->Options->Miscellaneous and select tab Files.
    • In File Extension row, click New button. Enter crazywrongname as extension name (this is important for option 2)
    • Below that, under Associated File Type (MIME): choose the option TWIG (text/x-twig)
    • click Apply and then OK.
    • Close Netbeans

    Option 1:

    The following steps are for CentOS 7 and NetBeans 8.1, most probably for other systems as well, but if you can't find the file at that path, option 2 is below.

    • open Terminal and open the file /root/.netbeans/8.1/config/Services/MIMEResolver/user-defined-mime-resolver.xml in your favourite text editor, e.g. run command nano /root/.netbeans/8.1/config/Services/MIMEResolver/user-defined-mime-resolver.xml
    • find the parameter name "crazywrongname" in this file and change it to "blade.php"
    • save the file
    • open Netbeans and enjoy.

    People from the future, you might try changing the Netbeans version in file path from option 1 to yours, like 14.3 or whatever is out in 2028.

    Option 2:

    If you can't find this file in the exact path as above, run this command to find it:

    cd / && grep -rI --exclude-dir=proc --exclude-dir=sys crazywrongname *
    

    This will start a search for the specific pattern on your whole system, starting at root. That's why we named the parameter crazywrongname - so it isn't found in any other file on the system, like blade would be. It will also exclude the folders that are not supposed to be accessed. If you don't exclude them, you will get errors and possibly hang your system. Also, some pink unicorns might die.

    After you find the exact file path for your system, follow the remaining steps in option 1 for changing the parameter name.

    Thank you, mysterious David Benedeki who disappeared from StackOverflow after answer which helped enormously :)

提交回复
热议问题