.m files as MATLAB/Octave for Sublime Text
Sublime 2 can be configured to associate certain file extensions to certain syntax highlighting schemes. See this answer for exactly how to do it https://stackoverflow.com/a/8014142/694184
Here is how to run Matlab/Octave code directly from Sublime Text with CTRL+B and associate .m
files to this Matlab syntax. Here it is specific for Windows, see the reason below in the note.
First a Matlab.sublime-build
:
{
"cmd": ["cmd", "/k", "D:\\Documents\\software\\octave-4.0.0\\bin\\octave-cli.exe", "$file"],
"selector": "source.matlab"
}
Then a Matlab.sublime-settings
:
{
"extensions":
[
"m"
]
}
Note: I used the cmd /k
trick to have the plot displayed in a new window that doesn't "disappear" after 10 milliseconds (see How to run Octave code without the Octave IDE (similarly to Python)? and Octave: How to prevent plot window from closing itself?). For this reason, don't forget to add this to your plots:
h = plot(...)
waitfor(h)