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?
Asked
Active
Viewed 5,082 times
14
-
For recent versions of `TextMate 2`, see this related question and answer: https://superuser.com/questions/1557143/textmate-2-add-a-file-association-to-an-existing-bundle – PatrickT Jun 02 '20 at 18:32
2 Answers
14
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.):
{ scopeName = 'text.xml';
fileTypes = ( 'xml', 'tld', 'jsp', 'pt', 'cpt', 'dtml', 'rss', 'opml' );
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.”
Telemachus
- 6,845
- 1
- 27
- 33
-
For other languages fileTypes isn't necessarily right at the top. For example, it was 2 - 3 pages down for me for ruby. Thanks for the answer though Telemachus. – umassthrower Aug 11 '12 at 15:39
-
@umassthrower Thanks for letting me know that. I generalized too quickly. Updated the answer to make that clearer. – Telemachus Aug 12 '12 at 01:05
-
This is perfect and helped me! Thanks. To be explicit: Bundles -> Bundle Editor -> Edit Languages -> XML -> Language Grammars -> XML. – gsscoder Mar 19 '17 at 08:34
-
@gsscoder Thanks for updating me. Question: are you using TextMate2? I just checked there, and the description is fairly different. I'll probably update this, but maybe leave the old description in case anyone is still using older versions of TextMate. – Telemachus Mar 19 '17 at 21:43
-
1In TextMate 2 the steps are: Bundles > Edit Bundles... > XML > Language Grammars > XML, and then edit the list of "File Types" in the drawer. – zengabor May 02 '18 at 18:47
-
-
TextMate version 2.0.6: I add extension `ncx` to the `Injection Selector` box and press the `+` button, but it adds empty lines instead. Moreover now every file's name has an `--ncx` appended to it in the toolbar. What am I doing wrong? – PatrickT Jun 02 '20 at 06:30
-
1@PatrickT I don't have TextMate installed any longer, and I'm not sure how the latest version works. You should consider opening a new question if it seems different. – Telemachus Jun 02 '20 at 10:45
-
3
Textmate 2 remembers the last language used for an extension.
You could customise the bundle if you wish
- ^⌥⌘-B (bundle editor) --> language grammars
- Add your extension to the "File Types" list (just click the
+icon
tim
- 409
- 3
- 6