Question

enter image description here

As shown in the above screen shot, the background of code (inside <? ... ?>) is different from the area outside PHP code. How can I change the background color of PHP code?

For example, if I change the language to Perl, the color is same inside and outside code:

enter image description here

Was it helpful?

Solution

Themes provide foreground, background and a font style (such as bold) to scopes.

A scope is defined in the languages grammar. These are available for each language under "Bundles" -> "Edit Bundles" -> [Language] -> "Language Grammars" -> [Language].

For your question specifically, you could place the cursor on the php line and press Control + Command + T then search for Copy or Show scope:

text.html.php
meta.embedded.block.php
source.php
keyword.operator.class.php
attr.os-version.10.8.5
attr.untitled

This shows that the scope you're looking for is called text.html.php or meta.embedded.block.php. Its probably not source.php because that would apply to the entire document.

Now all you need to do is modify the theme, you can tell what your current theme is via "View" -> "Themes", Then edit it with: "Bundles" -> "Edit Bundles" -> Themes -> Themes -> [theme]

I suspect you'd like to add or change something like this, though these colors are horrible.

{
  name = 'PHP: Variables Safer Globals';
  scope = 'meta.embedded.block.php';
  settings = {
     foreground = '#00FF00';
     background = '#FF0000';
   };
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top