Sublime Forum

Background color for php blocks

#1

Hello!
Is it possible to make the blocks of php code to have a different background just exactly like TextMate does it from end to end of the text area?

This is TextMate:

I really like how TextMate covers the entire block, not just from opening tag to closing tag.

Thank you in advance!

0 Likes

#2

Just assign the wanted background color to meta.embedded.block.php scope in your color scheme. To view the scope at the cursor position, use ctrl+alt+shift+p.

0 Likes

#3

Thank you! That worked almost exactly like the way TextMate looks.

I modified the Material regular and Darker schemes backgrounds for PHP scopes:

If anyone is interested here are the settings:

<!-- Material Theme PHP Scope Background Color -->
<dict>
	<key>name</key>
	<string>PHP Tags</string>
	<key>scope</key>
	<string>meta.embedded.line.php, meta.embedded.block.php</string>
	<key>settings</key>
	<dict>
		<key>background</key>
		<string>#232e33</string>
	</dict>
</dict>
<dict> 
	<key>name</key>
	<string>Line after PHP</string>
	<key>scope</key>
	<string>meta.html-newline-after-php.php</string>
	<key>settings</key>
	<dict>
		<key>background</key>
		<string>#263238</string>
	</dict>
</dict>

<!-- Material Theme Darker PHP Scope Background Color -->
<dict>
	<key>name</key>
	<string>PHP Tags</string>
	<key>scope</key>
	<string>meta.embedded.line.php, meta.embedded.block.php</string>
	<key>settings</key>
	<dict>
		<key>background</key>
		<string>#1e1e1e</string>
	</dict>
</dict>
<dict> 
	<key>name</key>
	<string>HTML Newline after PHP</string>
	<key>scope</key>
	<string>meta.html-newline-after-php.php</string>
	<key>settings</key>
	<dict>
		<key>background</key>
		<string>#212121</string>
	</dict>
</dict>

<!-- Material Theme Regular and Darker Selection Color Settings -->
<key>selection</key>
<string>#00000030</string>
<key>selectionBorder</key>
<string>#ffff0060</string>
<key>shadow</key>
<string>#00000010</string>
<key>stackGuide</key>
<string>#37474FFF</string>
0 Likes

#4

I’m new to Sublime Text and I’ve been looking for the exact same thing. Ividal, where do I enter that settings? To a file or using a command?

0 Likes