[TxMt] Re: Using „First Line Match” in grammars

Allan Odgaard mailinglist at textmate.org
Fri Oct 24 07:24:17 UTC 2014


On 23 Oct 2014, at 11:42, Stefan Daschek wrote:

> When and how is the “First Line Match” setting of language 
> grammars considered?

It is used after checking for explicit bindings (from tm properties). 
The explicit bindings are recorded in the Global.tmProperties when the 
user change language for an open file.

> In my experiments it doesn't seem to have any effect at all: For 
> example, I'd like TextMate to use the RSpec grammar for all *.rb 
> having a first line matching '.*spec_helper.*', but it seems to always 
> use the Rails grammar instead (even for newly created files). I 
> suspect TextMate remembers some kind of manual override – if so, how 
> can I reset this override? Is there any way to see (debug) how 
> TextMate choses the grammar?

With a *.rb file open you should be able to use ⌃⌘T, switch to 
settings, and then enter ‘filetype’ to find your explicit binding 
for *.rb → Rails in Global.tmProperties (although clicking Edit 
doesn’t take you to the proper line yet).

Making it work for RSpec files, assuming these still follow the 
file_spec.rb naming convention, you would need to change the setting to:

	[ *.rb~*_spec.rb ]
	fileType = source.ruby.rails


More information about the textmate mailing list