Sublime Text 2 with MATLAB Syntax – Windows

Sublime text does not recognize .m file from MATLAB after installation and show it in Object-c syntax. How to fix it?

Here is the solution:

sublime\_matlab

Select Preferences -> Browse Packages… to open your Packages folder, and open the Objective-C subfolder. Open Objective-C.tmLanguage in Sublime as an XML file (open it in sublime), and comment out (or remove entirely) Line 7:

<string>m</string>

Save the file and close it. Next, open Objective-C++.tmLanguage and do the same thing to Line 8:

<string>M</string>

Save and close that file as well.

Finally, just to make sure your Open all with current extension as… command worked, go to Packages/User and check for the existence of a file called MATLAB.sublime-settings. Open it as a JSON file, and double-check that its contents are as follows:

{
     "extensions";
     [
         "m"
     ]
}

If for some reason the file doesn’t exist, create it with the above contents and save it.

Preference – User – above contents – save it as ‘MATLAB.sublime-settings

You should now be able to open any .m file and have the syntax automatically set to MATLAB.

(This solution mainly come from http://stackoverflow.com/questions/24016186/setting-default-syntax-for-sublime-doesnt-work)