Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7680587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:08:57+00:00 2026-05-31T18:08:57+00:00

I would like to have the $ (dollar sign) which indicates a php variable

  • 0

I would like to have the $ (dollar sign) which indicates a php variable to appear as it’s own color (#ff0000) in ST2. I have been editing a custom color scheme file but cannot seem to get a special color for just this symbol.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:08:58+00:00Added an answer on May 31, 2026 at 6:08 pm

    Important Addendum Prefixed To The Answer

    The following explanation assumes that one is writing the syntax definition in JSON and then building the Plist xml file with the PackageDev plugin (as described in the unofficial sublime docs linked below). It is from the latter files that ST2 reads syntax parsing instructions.

    = = = =

    I’m reporting to you from my own first foray into this territory, so I may be mistaken on a point or two in what follows.

    Unless your syntax parser defines $ as having its own scope selector, you won’t be able to set the color for that lone sign through the color scheme files. As you may already know, you can check the scope selector of an element by selecting it and pressing option+command+p (alt+super+p on not-macs): it reports the information in the status bar.

    I just checked the php syntax parser on my own software, and there’s no differentiation between the scope of the $ and the string to which it is prefixed. Thus, assuming your setup is like my own, you’ll need to write your own syntax definition. This can be done either in the existing php syntax file, or (surely a safer option) in a new definition document which you’ll use as your primary one for editing.

    You can find a tutorial covering the basic steps of writing your own syntax definitions in the unofficial sublime text docs. In fact, a section therein, entitled “Fine Tuning Matches“, explains how to define a scope selector especially for prefixed dolla’ signs by using “captures”. You can refer to the documentation for the specifics on creating syntax definition files and all that, but, for the sake of solidifying my own understanding of the process and to make the answer readily available here, I’ll do my best to explain the JSON determination of the selector.

    This is the regex pattern you’ll need to use:

    { "match": "\\$([A-Za-z][A-Za-z0-9_]+)",
      "name": "keyword.syntaxTypeAbbreviation",
      "captures": {
        "1": { "name": "moreSpecific.selectorName.syntaxTypeAbbreviation " }
      },
      "comment": "Variables like $PARAM1, $TM_SELECTION..."
    }
    

    Analysis of the meaning of the above:

    "match" gives the regex which identifies the string pattern to be selected. Unless I’m mistaken, it reads, “any string beginning with ‘$’ ([followed by one uppercase or lowercase letter] and [at least one additional letter or numeral] plus any additional characters)”. (Sublime Text uses the oniguruma regex specifications.)

    "name" provides the string by which the the scope is to be selected in the color scheme document. In the scheme xml, this corresponds to the <key>name</key> <string>specific.selector.syntaxTypeAbbreviation</string>.

    "captures" (and this is the critical element for your aim) specifies the subset of the pattern which is to be given its own, more specific, scope selector. Each set of regex terms enclosed within parenthesis occupies one place, and the integer ("1", here) specifies which of the places is to be “captured”. In our case, of course, there is only the one capturable group.

    "name" does the same as before, but as a subspecies of the previous designation and, "comment" offers the option for you to comment on the significance of the definition.

    Finally, it is important to note that the first scope selector will set the color of the whole string and the second overrides its predecessor to give a different color to the following letters and numbers. That is to say, the first selector will let you color the $ and the second will be the color of the appended string.

    We can therefore translate the pattern thus:

    “Any string beginning with ‘$’ ([followed by one uppercase or
    lowercase letter] and [at least one additional letter or numeral] plus
    any additional characters) is to be named NAME, except for the part which is enclosed in the first set of parenthesis, which is to be named OTHERNAME instead.

    I hope that this explanation will be at lest half as useful for you to read as it has been for me to write. Also, I’d appreciate folks correcting whatever mistakes I surely did make.

    Regards,

    aBath

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a VM to look at how applications appear and
I would like to have information about the icons which are displayed alongside the
I have a problem that I would like have solved via a SQL query.
So in my project i would like have a nice treeview that has images.
I would like to have a reference for the pros and cons of using
I would like to have an iframe take as much vertical space as it
We would like to have user defined formulas in our c++ program. e.g. The
I would like to have a nice template for doing this in development. How
I would like to have all developers on my team to use the same
I would like to create 3 different arrays which can change depending on which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.