简体   繁体   中英

Sublimetext3 (javascript) - Change colour of expressions in template literals

So I'm using Sublime Text 3 text editor since recently and I keep stumbling upon something that I find annoying.. is it possible to have the ${variable} colour to be the same colour as the strings/template literals in a theme?

`The colour of a ${variable} in a template literal is always white regardless of string colour`

here's an example of my text editor with the current colours: current colours

here's an example of my desired text editor colours (photoshop): desired colours

just add that to the colour scheme of sublime

<dict>
    <key>name</key>
    <string>STACK DAT DOUGH</string>
    <key>scope</key>
    <string>punctuation.dollar</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#F92672</string> // desired color 
    </dict>
</dict>

Thanks for your reply @mooga, it wasn't the answer I was looking for, but you definitely put me on the right trail. This answer may not be what I wanted to have as my desired layout but this will make due, see pictures underneath!

original colours

desired colours

end result colours (using script below - this image is scuffed but mostly visible)

{
  "name": "Punctuation",
  "scope": "punctuation.definition",
  "foreground": "var(yellow)"
}

For those that read and wish to do this in the future, follow these steps:

  1. have sublime open
  2. open Tools -> select Command Parelette... (before next step, you may have to install PackageResourceViewer or something similar using Command Parelette... - I cannot remember how I did this before, you'll have to figure this out first)
  3. search and select: PackageResourceViewer: Open Resource
  4. search and select: Color Scheme - Default
  5. search and select: [YOUR_CURRENT_THEME].sublime-color-scheme (In my case: Monokai = I'm selecting Monokai.sublime-color-scheme )
  6. paste the script displayed above into "rules": [] ( view example )

More information can be found here: https://www.sublimetext.com/docs/3/scope_naming.html#punctuation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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