Thursday, October 3, 2013

Turn off Objective-C for m-files, Turn on MATLAB

I just posted about how cool Sublime Text 2 editor is, in Markdown builder for Sublime Text 2, but it's not all ice cream and apple pie. One thing that's a drag is that it always chooses Objective-C syntax for MATLAB. It's a pretty quick fix. Opening up the MATLAB language file found under packages in the preferences folder there's this comment re: file type
 <key>fileTypes</key>
 <array>
  <!-- Actually, it's generally .m, but that's taken by Objective-C. It needs an entry to show up in the syntax list. -->
  <string>matlab</string>
 </array>
Look in the Objective-C language file and you see this is indeed true, m-files are treated as Objective-C instead of MATLAB.
 <key>fileTypes</key>
 <array>
  <string>m</string>
  <string>h</string>
 </array>
Cut and paste <string>m</string> from the Objective-C file to the MATLAB file, and viola, it's all ice cream and apple pie!

Markdown builder for Sublime Text 2

By far the coolest editor around is Sublime Text 2. Set it to build Markdown using PyMarkdown
{
    "cmd": ["markdown_py.bat", "$file", "-f", "$file.html"],
    "selector": "text.html.markdown"
}
Save it in your Sublime preferences folder under Packages/User/Markdown.sublime-build. Now write some Markdown, hit ctrl-B and voila, HTML generated from your Markdown.
Fork me on GitHub