[TxMt] Re: Bug in Perl bundle

Allan Odgaard mailinglist at textmate.org
Sun Oct 19 19:24:37 UTC 2014


On 19 Oct 2014, at 15:24, Hans-Jörg Bibiko wrote:

> I've just encountered that the TAB snippet "pl" executed at the very 
> beginning of EACH document REGARDLESS of the set grammar inserts 
> "#!/usr/bin/env perl".
>
> Either the scope setting is wrong

This is meant as a feature and also works for rb⇥, py⇥, sh⇥, and 
maybe more.

Ideally TextMate would also switch file type when first line is changed 
to something that matches the “first line match” of a grammar. That 
way, if you want to create a new perl script, just ⌘N and enter pl⇥ 
and you have both the proper shebang and the file type automatically set 
(giving syntax highlight and an appropriate file name extension when 
saving).

> <key>scope</key>
> <string>L:dyn.caret.begin.document</string>
>
> [What does "L:" mean?]

L means “left”. The caret is technically between two characters, so 
we have a scope to the left and right of the caret. By default scope 
selectors look at what’s right of the caret, but sometimes it’s 
desired to look to the left instead, or maybe look to both sides, which 
can be done using B:«selector».

This is mostly when at the begin/end of an element, like string‸ 
versus ‸string.

In this case we target the “begin of document” attribute scope, 
which is to the left of the document’s first character. There are 
similiar attribute scopes for begin/end of line and end of document.


More information about the textmate mailing list