Menu

ALL reserved keywords for PHP and JavaScript!

beholder
2009-03-11
2012-11-13
  • beholder

    beholder - 2009-03-11

    I am actually still learning PHP and JavaScript and I found it quite confusing that Notepad++ doesn't have support for syntax highlighting of all keywords of these languages implemented. Neither could I find some complete listing of these keywords so I had to resort to search through the internet.

    Ultimately, I have discovered some lists for PHP and JavaScript languages. These lists contain most, if not all, functions and reserved keywords used in both languages. Beginners in these languages usually know that for example a function or a property they desire exists, but they don't know its correct name. This way they don't have to consult manual too often, they can just write the function name and see if it is recognized as 'reserved'.

    I have no idea where I have the PHP keywords list from but here are almost all functions of this language:
    http://tigerware.sk/php_keywords.txt
    Since Notepad++ doesn't actually allow all of these keywords to be inputted into the user defined keywords box (hello Don), you must edit the Application Data/stylers.xml and in PHP section change one specific <WordsStyle> tag to this:
    <WordsStyle name="WORD" styleID="121" fgColor="005E00" bgColor="FEFCF5" fontName="" fontStyle="1" fontSize="" keywordClass="instre1"> PUT ALL OF THE NEW KEYWORDS HERE </WordsStyle>
    This WORKS! it is tested.

    Now JavaScript. It is even more confusing language than PHP, because it CASE SENSITIVE and has many classes, elements, etc.  from Document Object Model. Therefore many specific keywords. Since Notepad++ doesn't allow us to create classes etc. in in-built style configurator for javascript, I just added all of them to the user keywords box (this time it's not too many for the box so it works). I have had a dillema with this, since some DOM objects (like "a". "i" etc.) could sometimes  be used as a variable, but I put them in anyway. Here is the list:
    http://tigerware.sk/javascript_keywords.txt

    BTW, Don, JavaScript syntax highlighting definitely needs some improvement. Unless I create my own custom language, the built-in support for this language limits itself to a few keywords while you have a whole DOM structure on hands when dealing with this. Something like in CSS support would be welcome here. Here is a perfect reference for this, it lists every reserved keyword with a category it belongs to:
    http://de.selfhtml.org/navigation/syntax.htm#javascript
    With such a reference, I imagine it would take you half-an-hour to get this to work properly. Cheers!

     
    • beholder

      beholder - 2009-03-26

      I have had the same problem as you. Unfortunately there seems to be no solution right now other than to define YOUR OWN custom language in the custom language definition feature of Notepad++. Try that, I think it's worth the effort.

      I personally don't mind the same color for all keywords/functions. BTW NPP seems very resistant to changing the pre-defined syntax highlighting, hopefully that will change with future versions.

       
      • MaY

        MaY - 2009-03-27

        will the custom language work in multihighlighting like php? I mean, html/js/css/custom alltogether?

         
    • beholder

      beholder - 2009-03-11

      Don, perhaps you could upload these files (along with a short guide) to your website, so I don't have to host them. I didn't notice any section on more reserved keywords for programming languages, maybe it's time to create it.

       
    • Dženan Zukić

      Dženan Zukić - 2009-03-13

      Those (http://tigerware.sk/php_keywords.txt and http://tigerware.sk/javascript_keywords.txt\) are not reserved words. Those are library functions (and variables?).

       
    • beholder

      beholder - 2009-03-15

      Yes, my point is to add them to the user keywords list so that they are highlighted. Current JavaScript syntax highlighting feature in NPP doesn't actually allow anything else.

       
    • MaY

      MaY - 2009-03-15

      Yeah.. I just liked the shiny Notepad++, but the absense of built-in functions highlighting (which is one of the core functions of any editors, in my opinion) is a reason to stay with CrimsonEditor, which is old as hell, but at least contains essential things

       
      • beholder

        beholder - 2009-03-20

        Hi, mayteks,

        I do encourage you to try NPP once again, because it is very easy to get all of the functions of a particular language highlighted. If you have any trouble with it, let me know here, I can help you set it up.

         
        • MaY

          MaY - 2009-03-24

          hey. I tried the way you described in top post. Although this looks better than nothing, I don't like the function names being highlighted with the same color as keyword like "public" or "function".

          I tried to create another WordStyle tag in php section, like: <WordsStyle name="KEYWORD" styleID="117" fgColor="FF0000" bgColor="F2F2F9" fontName="" fontStyle="0" fontSize="" keywordClass="instre2">

          .. and all the keywords are being shown in stylers configurator, but highlighting just doesn't work. If I set keywordClass to "instre1" instead of "instre2", then everything gets highlighted as with your method.

          Until there's no tidy solution, I'd stay with CE. I can't get it, why it must be so impossible to let users extend default stylers.

           
MongoDB Logo MongoDB