Regexp to match but don't capture middle part - sublimetext2

Im trying to create my own theme in Sublime Text 2 to highlight CSS syntax. All I have left is keyframes.
#-webkit-keyframes spin { /* some rules */ }
#-moz-keyframes colorize { /* some rules */ }
#-ms-keyframes spin { /* some rules */ }
#-o-keyframes spin { /* some rules */ }
#keyframes colorize { /* some rules */ }
I want to highlight the initial # and the word keyframes without highlighting engines prefixes, like -webkit-, or -moz-, so only #keyframes must be returned.
What is the right regexp for that?
I tried:
((?<=-webkit-)|(?<=-moz-)|(?<=-ms-)|(?<=-o-)|)keyframes
but that doesn't include the # and doesn't even return the keyframes in Sublime text at all.
Update ----
Thanks to Cheruvian, I realized what was in front of me all along.
Sublime's parser structure is (I added the comments after I realized what are the <key>name</key>):
<dict>
<!-- Regexp pattern -->
<key>match</key>
<string>\s*(#)(-(webkit|moz|ms|o)-)?(keyframes)</string>
<!-- Referencing to the groups captured above -->
<key>captures</key>
<dict>
<!-- 1st group captured -->
<key>1</key>
<dict>
<!-- Referencing name -->
<key>name</key>
<string>keyword.control.keyframes.css</string>
</dict>
<!-- 2nd group captured -->
<key>2</key>
<dict>
<!-- Referencing name -->
<key>name</key>
<string>punctuation.definition.keyword.css</string>
</dict>
<!-- n group captured -->
<key>n</key>
<dict>
<!-- Referencing name -->
<key>name</key>
<string>some.name.css</string>
</dict>
</dict>
</dict>
From that, all I had to do was to group the regex and select the groups I wanted and give them some unique referencing strings.

Assuming sublime uses capturing groups you can use:
(#).*?(keyframes)
regex capturing groups are indicated by parentheses.
(From phone will try to clean up later)

Related

Highlighting tab characters in Sublime Text (2 or 3)

Is there a way I can highlight just tab characters? I know about "draw_white_space": "all" but I don't want to highlight all whitespace, just tabs.
There doesn't seem to be a plugin or a setting that fits the bill. I'd like to avoid writing a new plugin, but I will if I have to.
Thanks in advance!
I haven't worked on this plugin in a while, but you can try PersistentRegexHighlight. You will just need to define a regex pattern for the tabs and a color to highlight with if you don't like the default.
I have only tested this on SublimeText2. As an alternative to PersistentRegexHighlight, you could use the following minor modifications to the theme and language files. Please feel free to disregard / remove the whitespace definitions -- I included them because someone else may be interested in seeing how to modify Theme / Language files:
Excerpt from whatever language syntax you want -- e.g., LaTeX.tmLanguage
<!-- BEGIN whitespace / tab definitions -->
<dict>
<key>match</key>
<string>\t+</string>
<key>name</key>
<string>lawlist.tab</string>
</dict>
<dict>
<key>match</key>
<string> +</string>
<key>name</key>
<string>lawlist.space</string>
</dict>
<!-- END -->
Excerpt from whatever theme you are using -- e.g., lawlist.tmTheme
<!-- BEGIN whitespace / tab definitions -->
<dict>
<key>scope</key>
<string>lawlist.tab</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#FF0000</string>
<key>background</key>
<string>#FFFFFF</string>
</dict>
</dict>
<dict>
<key>scope</key>
<string>lawlist.space</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#000000</string>
<key>background</key>
<string>#FFFFFF</string>
</dict>
</dict>
<!-- END whitespace / tab definitions -->

Change apparance of whitespace dot to something bigger / darker

I am looking for a way to change the appearance of the whitespace grey dot to something bigger and darker (without changing the background color) -- similar to UltraEdit (see screenshot).
I've read all the popular threads on the issue, and I've tried all the popular modifications (e.g., plugins, and/or changing the language and theme files), but I haven't found a way to darken the grey dot or make it any bigger.
I've already experimented with everything mentioned in this related thread, including the links set forth therein: Sublime Text 2: how to change white space characters color?
(source: lawlist.com)
.tmTheme
<!-- BEGIN whitespace / tab definitions -->
<dict>
<key>scope</key>
<string>lawlist.tab</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#FF0000</string>
<key>background</key>
<string>#FFFFFF</string>
</dict>
</dict>
<dict>
<key>scope</key>
<string>lawlist.space</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#000000</string>
<key>background</key>
<string>#FFFFFF</string>
</dict>
</dict>
<!-- END whitespace / tab definitions -->
.tmLanguage
<!-- BEGIN whitespace / tab definitions -->
<dict>
<key>match</key>
<string>\t+</string>
<key>name</key>
<string>lawlist.tab</string>
</dict>
<dict>
<key>match</key>
<string> +</string>
<key>name</key>
<string>lawlist.space</string>
</dict>
<!-- END -->
Someone bumped a post on the ST forum about coloring white space and I thought of this post. You may see it too, but just in case, I'll post here. Basically they modified the tmLanguage file to give a new scope to leading whitespace. They then applied a color to that.
https://github.com/ckovey/sublime-whitespace-coloring
There is no solution to this issue.

Sublime Text 2 HTML syntax highlighting issue

I am having a problem with the syntax highlighting for HTML (and plaintext) in Sublime Text 2,
as it only grays out the lines as in the image.
Whenever I shift to Python, JavaScript, and other languages, the highlighting works fine.
I am new to Sublime Text 2, so it is probably an easy answer, but I did not know how to formulate the issue without showing an image.
I dont't think it is a problem, it's just how the theme "All Hallow's Eve" works:
You can change the this color inside this block: (Preferences->Browse Packages>Color Scheme - Default->All Hallow's Eve)
<dict>
<key>name</key>
<string>Text base</string>
<key>scope</key>
<string>text</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#434242</string> #THIS IS GRAY COLOR YOU WANNA CHANGE.
<key>foreground</key>
<string>#FFFFFF</string>
</dict>
</dict>
I found the problem; it seems like the color scheme "All Hallow's Eve" is not
working very well on HTML, so I simply changed the color scheme.

How to modify the colour scheme in Sublime Text 2 for php tags

In some themes in sublime text, the background colour of the area within certain tags like script or php is of a different colour from the rest of the code. For example like that in the iPlastic or twilight theme.
For Example: http://imageshack.us/photo/my-images/541/screenshot20130207at342.png/
I hope to achieve the same effect in the Tomorrow colour scheme which does not have this by default. I understand that i have to edit the .tmTheme file, but I am not sure of the code I am supposed to put in.
Any help would be much appreciated.
Thanks!
You should add something like this to your .tmTheme file:
<dict>
<key>name</key>
<string>Embedded source</string>
<key>scope</key>
<string>text source</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#FCFCFC</string>
</dict>
</dict>
Of course you can set the colors that you prefer.
Open with Sublime the .tmTheme file you want to edit, and first of all save it with a different name (but with the same extension). Then look for this:
<string>text source</string>
This is present only in some of the .tmTheme files! In the file iPlastic.tmTheme file you mentioned, you will find it in this entry:
<dict>
<key>name</key>
<string>Embedded source</string>
<key>scope</key>
<string>text source</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#FAFAFAFC</string>
<key>foreground</key>
<string>#000000</string>
</dict>
</dict>
If .tmTheme files were written in JSON instead of this clumsy XML, the entry would look like this:
{
"name": "Embedded source",
"scope": "text source",
"settings": {
"background": "#FAFAFAFC",
"foreground": "#000000"
}
},
In this case the background value is almost white (0xFA in all three channels), but a tiny bit transparent (0xFC opacity). The result depends on the background value you find towards the start of the file, which in this case is #EEEEEEEB (notice the absence of name and scope):
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#EEEEEEEB</string>
The 0xEB opacity, as far as I can tell, is ignored here, since the default background is #EE. #FA with 0xFC opacity gets composited over #EE as #F9 (which makes sense).
Now, if you want to force the background of the text source scope to some value, you have to change its <dict> entry if it's present, and add it if it's not.
If, on the other hand, you want to make the background of the text source scope equal to all the rest, what you have to do is simply to delete its <dict> entry.
Remember that a 3-byte value like #AABBCC is 100% opaque, i.e., it has 0xFF opacity, i.e., it is equivalent to the 4-byte value #AABBCCFF.
Keep also in mind that you may put the modified .tmTheme file underneath, e.g., the PHP subdirectory of Packages, instead of the Color Scheme - Default subdirectory. This is particularly useful for PHP, where the default background is the one outside of <?php...?>, while the one inside is the one of the text source scope (this is an artifact of the trick used in order to inherit the settings for the HTML file type). Unless your PHP files contain lots of HTML (or whatever you have outside <?php...?>), you might want to put underneath PHP a theme with a background value for text source equal to the default background value for other file types, and a different default background value just for PHP files.

CSS3 elements color in sublime

I have been using sublime for about half and year and now i want to make some modifies to it. I installed few packages and rest of stuff but i have a kind of problem.
Using theme Monokai ( and also in other tested themes ), i can't give the right color to attributes like "-webkit-box-shadow" and other css3 elements. I mean, i would like to have the right color also for vendor prefixes and new css3 elements.
Add this <dict> entry to your .tmTheme file to have the right colors for all (also unknown) css property names:
<dict>
<key>name</key>
<string>CSS property name</string>
<key>scope</key>
<string>meta.property-name.css</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#66D9EF</string>
</dict>
</dict>
I found a plugin that solves my problem https://github.com/i-akhmadullin/Sublime-CSS . Closed !