[TxMt] Changing language for a specific file

Hans-Joerg Bibiko bibiko at eva.mpg.de
Wed Jan 9 07:46:40 UTC 2008


On 8 Jan 2008, at 21:57, Thomas Aylott - subtleGradient wrote:
> On Jan 8, 2008, at 1:38 PM, Nate Cavanaugh wrote:
>> Quick question, do you know if this is possible with TabMate  
>> *without*
>> modelines? I'm working on a huge code base with multiple users and  
>> strict
>> coding standards and the modelines aren't allowed to sit in SVN,  
>> which means
>> I have to copy the mode lines every time I edit the file, in which  
>> case, I
>> might as well just manually change the language.
>>
>> Anyone know of a work around (even if it's a work around in SVN)?
> AFAIK, the only options are: change it every time you open the  
> file. Use tabmate with modelines. Change the file extension. Or  
> change the language syntaxes to support that file extension.
The last option would be the most elegant way.

For private usage one could also do this with the plugin TMTOOLS  
http://email.eva.mpg.de/~bibiko/downloads/textmate/

write a simple command "Open as CSS" bound to any key equivalent à la:

"$TMTOOLS" show openPanel
"$TMTOOLS" set grammar '{to="CSS";}'

or

a command "Set grammar to CSS"
"$TMTOOLS" set grammar '{to="CSS";}'

Thus you only have to press one single key.

If you have many files like that one also could think about to  
maintain a file containing file names and grammar like

header.jsp TAB css
script.jsp TAB JavaScript
...

and use "$TMTOOLS" show openPanel followed by a script which parses  
that file and sets the according grammar.

Furthermore to maintain that file easily one can write a command  
"Remember Grammar" and make usage of:
GRAM=$("$TMTOOLS" get currentGrammar)
echo "$TM_FILENAME	$GRAM" >> myFILEwithGRAMMARS

--Hans


More information about the textmate mailing list