Scope (was: [TxMt] <img> & <css> drag commands)

Allan Odgaard allan at macromates.com
Wed May 25 23:37:58 UTC 2005


On May 25, 2005, at 22:44, Ben Parzybok wrote:

> The one thing that was different was the scope field, which I guess  
> I don't understand yet.

The scope is where the command should be active (i.e. the language).

If you have enabled the Language Definition bundle then try e.g. to  
place the caret on a string in PHP in HTML, then press ctrl-shift-T  
(a command that shows the current scope as a tooltip), it should show:
    text.html.basic
    source.php.embedded.html
    string.double-quoted.php

This is the scope that the caret is in, and you can limit settings,  
styles, and bundle items to work only for a given scope.

So scopes are very much like CSS selectors -- also, when you enter  
the scope, TextMate performs pattern matching, so you don't have to  
enter all of it, e.g. you could just enter: “string” and the (in this  
case) drag command would only be used, when you drag stuff onto strings.

For something like a drag command you'd just set the first part of  
the scope, i.e. text.html versus text.latex or source.css. This btw  
means that if you have <style>...</style> in a HTML file, dragging  
stuff to that section will get the appropriate drag command scoped to  
source.css, where dragging to outside this section will result in the  
commands scoped to text.html.

There should be coverage of this in the release notes (for 1.1b6).





More information about the textmate mailing list