I would like TextMate to recognize that RDF files are XML and highlight them as such but I can't seem to find a way to do this through the UI. Is there a way to add file extension/type associations?
MacOS – TextMate File Type Association Guide
file associationmacostextmate
Related Solutions
I found this in Windows help:
To associate a file name extension with a file type:
- Open Folder Options in Control Panel.
- Click Start, and then click Control Panel.
- Double-click Folder Options.
- On the File Types tab, click New.
- Type a new or existing file name extension, and then click Advanced.
- In Associated File Type, select a different file type to associate with the extension.
If you click New and type in rrx, you can associate that with XML document, so you can then use the XML document default programs.
You'll have to associate the MKV extension with a batch file or PowerShell/VB script that in turn performs the file size check and invokes the appropriate application.
Here's how to do it with a batch file:
Open regedit, navigate to
HKEY_CLASSES_ROOT\.mkv
and note the (Default) value. This is the ProgID. Let's assume it's mkvfile.Navigate to
HKEY_CLASSES_ROOT\mkvfile\shell\open\command
and modify the (Default) value to something like"D:\MKVSizeCheck.bat" "%1"
.Now create the
D:\MKVSizeCheck.bat
batch file with the following contents:if %~z1 leq 524288000 ( start "" /max "C:\Program Files\VLC\VLC.exe" "%~1" ) else ( start "" /max "C:\Program Files\PowerDVD\PowerDVD.exe" "%~1" )
Here's how to do it with VBScript:
Same as above.
Navigate to
HKEY_CLASSES_ROOT\mkvfile\shell\open\command
and modify the (Default) value to something likewscript //B "D:\MKVSizeCheck.vbs" "%1"
.Now create the
D:\MKVSizeCheck.vbs
file with the following contents:set objArgs = WScript.Arguments set objShell = WScript.CreateObject("WScript.Shell") set objFSO = WScript.CreateObject("Scripting.FileSystemObject") if objFSO.GetFile(objArgs.Item(0)).Size <= 524288000 then objShell.Run """C:\Program Files\VLC\VLC.exe"" """ & objArgs.Item(0) & """", 3, false else objShell.Run """C:\Program Files\PowerDVD\PowerDVD.exe"" """ & objArgs.Item(0) & """", 3, false end if
Note #1: Modify the paths as required obviously. Also the code above sets 500MB (= 524288000 bytes) as the threshold so change that too as per your needs (very large values may be possible only in VBScript though).
Note #2: You can always use a utility like FileTypesMan to do steps 1-2 if you're unsure about manually editing the registry.
Note #3: Using a batch file will cause a console window to flash which might be irritating. Now this can be hidden using something like Hidden Start or VBScript, but why bother when it's better to directly use VBScript in the first place.
Best Answer
In the menu, go to Bundles -> Bundle Editor -> Edit Languages -> XML -> XML. (That is, in the section XML, you have both XML and XSL.)
Then in the grammar you will see in the right pane, add RDF files to the
fileTypes
section. (That section is right at the top of the grammar in this case, but as @umassthrower points out, it may be later.):See this link for more gory details on filetype associations.
Per @zengabor in a comment, “In TextMate 2 the steps are: Bundles > Edit Bundles... > XML > Language Grammars > XML, and then edit the list of "File Types" in the drawer.”