I have the following code in a php page:


$query = "
    SELECT data 
    FROM table 
    WHERE param = 1 

Since this sql is wrapped inside quotations in a php document, everything shows up a solid green (or whatever color you have set for a string's syntax highlight).

Is there a way to get sublime text 2 to properly color the sql even with it inside a php string?


On my Sublime this code works great:

$query = "SELECT data FROM table WHERE param = 1 ";

Don't add new line after '='


You will have to edit the PHP.tmLanguage located in Data\Packages\PHP. You should probably set a regex rule (as MySQL queries begin with SELECT/DESCRIBE etc.) and assign proper context.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.