[TxMt] Filename Extensions

Steve King sking at arbor.net
Thu Apr 24 19:46:17 UTC 2008

In another thread Allan Odgaard wrote:
> TextMate will not search binary files, granted it knows that the file 
> type is binary. So right-click a file (using the extension you want to 
> exclude) in the project drawer and select to treat it as binary.

That helps, but isn't perfect.  For one thing, it can't handle files 
without an extension, such as executables.  If I just open a directory 
as a project, it's likely to be a mixed bag of source, object, and 
executable files.  It's easy enough to tell TextMate to skip the object 
(*.o) files, but how do I tell it that the executable named "xyzzy" is 

There's another quirk related to filename extensions that drives me 
nuts.  For various reasons, I have a lot of files with the extension 
"*.txt" which actually contain different types of data. We have, for 
instance, configuration files, SNMP MIB files, and plain ol' text files 
sharing that extension. I'd like different syntax highlighting rules to 
be used for each.  So I open "foo.txt" and change the language to 
"MIB".  Then I open "bar.txt" and change to "plain text", and so on.  It 
seems that every time I open a file with the *.txt extension I have to 
fiddle with the language.

(Yeah, if it were up to me I'd give all these files different 
extensions. Unfortunately the naming conventions were established long 
before I was hired here!)

Since the majority of *.txt files I edit actually are plain text, I 
think it'd be great if I could tell TextMate explicitly, "Treat *.txt as 
plain text unless I tell you specifically otherwise" instead of having 
it automatically change the definition of the whole extension whenever I 
switch.  I'd still end up changing types, but at least it'd cut down on 
how often I'd need to. Bonus points for remembering which full filenames 
have been manually mapped to something else.

What would be even better would be for TextMate to examine the contents 
of the file as well as the filename to determine what language it is.  
If the extension is ambiguous, check the first few bytes for a shell 
shebang line, or an emacs-style modeline, or some other clue as to the 
type.  And I would absolutely swoon if the language definition itself 
contained a way to specify what to look for, letting TextMate try each 
language in turn until it found a match.

Steve King
Sr. Software Engineer
Arbor Networks
+1 734 821 1461
www.arbornetworks.com <http://www.arbornetworks.com/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20080424/704ecf4e/attachment.html>

More information about the textmate mailing list