I'm new to TextMate and am already recommending it to my students, but I don't understand the conventions for Scope Selectors.
Let's say I want to color all div tags in HTML red. I've tried variations on "entity.tag.div" in Prefs > Fonts & Colors without success. I've a basic familiarity with RegExp, and it looks like Bundle grammar supports RegExp, but I can't see where syntax coloring might be defined in the HTML Bundle either.
(For the record, I also can't figure out how to duplicate a Theme--say, if I want to tweak a version of the default Theme but keep the original too.)
Thanks for any help getting me going in the right direction.
jon
Hi,
Although I don't really mess with themes, this should be close to accurate:
I'm new to TextMate and am already recommending it to my students, but I don't understand the conventions for Scope Selectors.
Scope selectors start from the general scope, and get more specific after each dot.
For the sake of example, let's look at the iPlastic theme.
The "String" element has a scope of string, and the "Regular Expression" has a scope of string.regexp
A regex is to be considered as a special case of a string (I guess is one way to think of it)
You can find out what scope is assigned to different parts of your document by mousing over them and hitting ctrl-shift-p
If you are writng HTML, for example, mouse over a tag (say <p>) and hit ctrl-shift-p You'll see a tool tip for the scope .. for instance, I see:
text.html.basic meta.tag.any.html entity.name.tag.html
All three "rules" may apply to that thing (I'm not sure what the precedence is between them (is it in increasing or decreasing order)).
Now look again at iPlastic, you'll see that the last rule/coloring for "Tag" matches entity.name.tag
Since <p> is "a special case" of entity.name.tag (namely, entity.name.tag.html), <p> is in this scope and gets colored w/ that blue.
Make sense?
Let's say I want to color all div tags in HTML red. I've tried variations on "entity.tag.div" in Prefs > Fonts & Colors without success. I've a basic familiarity with RegExp, and it looks like Bundle grammar supports RegExp, but I can't see where syntax coloring might be defined in the HTML Bundle either.
(For the record, I also can't figure out how to duplicate a Theme-- say, if I want to tweak a version of the default Theme but keep the original too.)
Go to TextMate > Preferences > Fonts & Colors
Click on the theme list dropdown. On the bottom is "Edit Theme List ..." You can then click on the theme you want to duplicate and hit the plus-plus button (the middle option on the bottom left three-button combo)
Hope that helps,
-steve
On Feb 13, 2007, at 1:29 PM, Jon Ippolito wrote:
Let's say I want to color all div tags in HTML red. I've tried variations on "entity.tag.div" in Prefs > Fonts & Colors without success. I've a basic familiarity with RegExp, and it looks like Bundle grammar supports RegExp, but I can't see where syntax coloring might be defined in the HTML Bundle either.
As an addendum to what Steve has said, the grammar is full of rules that give names to things (scopes). In the grammar, this appears as a name=... thing. You can basically target those.
In your particular case, the div is matched in the grammar in the exact same way as any other tag, so there is no way to color it separately, unless you alter the grammar.
Some doc references:
http://macromates.com/textmate/manual/ language_grammars#language_grammars http://macromates.com/textmate/manual/scope_selectors#scope_selectors http://macromates.com/textmate/manual/themes#themes
Haris