How do I set a default filetype for a certain file extension in Sublime Text 2? Specifically I want to have *.cfg files default to having Ini syntax highlighting but I cannot seem to figure out how I could create this custom setting.
Join Stack Overflow to learn, share knowledge, and build your career.
|
In the current version of Sublime Text 2 (Build: 2139), you can set the syntax for all files of a certain file extension using an option in the menu bar. Open a file with the extension you want to set a default for and navigate through the following menus: Updated 2012-06-28: Recent builds of Sublime Text 2 (at least since Build 2181) have allowed the syntax to be set by clicking the current syntax type in the lower right corner of the window. This will open the syntax selection menu with the option to Updated 2016-04-19: As of now, this also works for Sublime Text 3. |
|||||||||||||||||||||
|
|
Go to a
And then restart Sublime Text |
|||||||||||||||||||||
|
|
You can turn on syntax highlighting based on the contents of the file. For example, my Makefiles regardless of their extension the first line as follows:
This is typical practice for other editors such as vim. However, for this to work you need to modify the
Note, that is really a zip file. Copy it, rename with .zip at the end, and extract the Makefile.tmLanguage file from it.
All the files matching the first line rule should turn the syntax highlighting on when opened. |
|||||
|
|
In ST2 there's a package you can install called Default FileType which does just that. More info on https://github.com/spadgos/sublime-DefaultFileType. |
|||||||||||||
|