Home Download Buy Blog Forum Support

In PHP, different color coding for different comment types

In PHP, different color coding for different comment types

Postby rebatch on Sun Jul 28, 2013 7:12 pm

Hey all,

Glad to see the Sublime 3 development rolling along.

In my work environment, we tend to use two of the PHP comment tag styles in different ways. We will usually use double-slash (//) to indicate a removed piece of code, whereas we'll use the hash mark (#) for a one-line comment.

So, if you have something like this...

Code: Select all
# This code is meant to amuse yet frighten players
echo 'It is pitch black. You are likely to be eaten by a grue.';
// echo 'All your base are belong to us';


Ideally I would pick a very muted color for the '//' comments but perhaps something more visible for the '#'s.

I think the color-themes assign both of these (// and #) as "comments", so color changes impact both. Would the trick be to find where '//' and '#' were defined, give them their own names ('comment-details' verses 'comment-deactivate') and then be able to assign different colors for each (when using PHP)?

Thanks,
Roy
rebatch
 
Posts: 1
Joined: Sun Jul 28, 2013 7:00 pm

Re: In PHP, different color coding for different comment types

Postby iamntz on Sun Jul 28, 2013 8:26 pm

You have scopes for each comment type!:

1) comment.block.php /* */
2) comment.line.double-slash.php //
3) comment.line.number-sign.php #

Image


Just add this into your theme file and update colors (hint: search for comment in existing theme, to nicely group stuff together)
Code: Select all
<dict>
  <key>name</key>
  <string>Block Comment</string>
  <key>scope</key>
  <string>comment.block.php</string>
  <key>settings</key>
  <dict>
    <key>foreground</key>
    <string>#CC0000</string>
  </dict>
</dict>

<dict>
  <key>name</key>
  <string>Slash Comment</string>
  <key>scope</key>
  <string>comment.line.double-slash.php</string>
  <key>settings</key>
  <dict>
    <key>foreground</key>
    <string>#00CC00</string>
  </dict>
</dict>

<dict>
  <key>name</key>
  <string>Hash Comment</string>
  <key>scope</key>
  <string>comment.line.number-sign.php</string>
  <key>settings</key>
  <dict>
    <key>foreground</key>
    <string>#0000CC</string>
  </dict>
</dict>
iamntz
 
Posts: 898
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania


Return to General Discussion

Who is online

Users browsing this forum: Google [Bot], Trussell, vkocubinsky and 17 guests