Sublime Text 3 - Detect syntax based on file header
ApplySyntax plugin does handle cases, when you need different syntax for files with the same extension and many more.
To expand on Gerard Roche's answer, if you're wondering how to find these syntax definition files in Sublime Text 3, I found this answer helpful.
To summarize: on MacOS X, the package files live at /Applications/Sublime Text.app/Contents/MacOS/Packages
and are all zip files even if they don't show the extension. To change the syntax definitions,
- Create a new folder where you'll unzip to (if you unzip in place, it's harder to keep track of all the files).
- Copy the language file you wish to modify into this folder and unzip it. Then rename the previous language file as a backup.
- Open the
<Language>.sublime-syntax
file and change thefirst_line_match
rule to whatever you need. - Zip all of the files back together again using a no-compression zip, name the zip file the same as the original file and then move it back out to the
Packages
folder.
Thanks to xmnboy for pointing out that the zip files can't be compressed.