Sublime Forum

PHP syntax highlighting between HTML quotes

#1

I am THIS close in to purchasing a ST licence, it really is a beautiful program and i really want to get rid of editing in Dreamweaver.

But i just can’t seem to find how it’s possible to get the right PHP syntax highlighting when working with a PHP / HTML combination.
And that’s kind of important.

One may use PHP code inside HTML quotes like in the screenshot, but the the PHP syntax isn’t right anymore.

The screenshot where highlighting is good is in Dreamweaver, how to get it functioning like that in ST2?



0 Likes

#2

You must edit your .tmTheme file

0 Likes

#3

Yes it seems to be that way, but i’ve no clue where or how, even when going through the docs.

I keep reading from sublime text lovers and users how active it is with the community and all, but i get the feeling it’s more dead than alive since there are way more questions than good answers really…

0 Likes

#4

I notice this too, this seems happens for all default color schemes. You can use some of Tomorrow Color Schemes: github.com/chriskempson/tomorro … r/textmate

Than it’s look like this:

0 Likes

#5

If you don’t wish tackle the customization yourself then you might find a theme, such as Tomorrow, that already includes some embedded-php highlighting.

Otherwise, you might modify (copy and save etc.) your current theme to include rules such as the following:

<key>name</key> <string>Embedded begin (PHP)</string> <key>scope</key> <string>text.html.basic source.php.embedded.block.html punctuation.section.embedded.begin.php</string> <key>settings</key> <dict> <key>fontStyle</key> <string></string> <key>foreground</key> <string>#FF0000</string> </dict> </dict> <dict> <key>name</key> <string>Embedded end (PHP)</string> <key>scope</key> <string>text.html.basic source.php.embedded.block.html punctuation.section.embedded.end.php</string> <key>settings</key> <dict> <key>fontStyle</key> <string></string> <key>foreground</key> <string>#FF0000</string> </dict> </dict>
Use Ctrl-Alt-Shift-P to discover the current scope for particular text that you wish to colour - it appears in the statusbar - or install the **ScopeHunter **package.

0 Likes

#6

I have question about scope. Look at my screen, why sublime detect scope as wrong? Why not as embed php in javascript string quotes?


0 Likes

Color scheme changes
#7

Thanks everybody for their great answers.
ST is such a great editor with superbe modification possibilities so i’ll to learn many new things.

In the meanwhile i got what a wanted!

I’ve found a Monokai expanded theme which includes embedded php highlighting like it should.

For every who’s still searching check this out: travisjbeck.com/blog/php/monokai … edded-php/

Also have a look at that great theme editor ( open in chrome ): tmtheme-editor.herokuapp.com/#/Monokai

I’m going to purchase Sublime now becuase i want this editor to be supported as much as possible!

0 Likes

#8

Your echo statements should be semi-colon terminated, although this probably doesn’t account for the scope issue. I don’t think ST-scoping extends as far as HTML > JS > STRING > PHP.

0 Likes