[ACCEPTED]-.m files as MATLAB/Octave for Sublime Text-sublimetext
Sublime 2 can be configured to associate 3 certain file extensions to certain syntax 2 highlighting schemes. See this answer 1 for exactly how to do it https://stackoverflow.com/a/8014142/694184
Here is how to run Matlab/Octave code directly 8 from Sublime Text with CTRL+B and associate .m
files 7 to this Matlab syntax. Here it is specific 6 for Windows, see the reason below in the 5 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 4 to have the plot displayed in a new window 3 that doesn't "disappear" after 2 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 1 forget to add this to your plots:
h = plot(...)
waitfor(h)
Are those files scripts or functions? If 15 they are Octave scripts and not functions 14 then you can have any extension you like 13 and use source()
to run them, independently of the 12 extension. If they are functions, unlike 11 Matlab you can define functions in a script 10 file, load it, and they will stay in memory.
But 9 if you don't need syntax highlight at all, you 8 should be able to change Sublime, just find 7 the file Objective-C.Sublime-package. Without 6 running it, just by looking at the files 5 in the installer, I see two ways to do it:
- try to remove it (or just change its name for something .bak so you can restore it in case something goes wrong)
- that file is a tarball with two XML files. Open those files and edit the entry that sets what's the extension for those files for something different of .m
And 4 of course, there's also the option of change 3 to a free as in freedom text editor that 2 allows you to look in their source and do 1 whatever you want.
This worked fine for me. I had just put 2 the path for the octave and the code is 1 perfectly running
{
"cmd": ["/usr/local/octave/3.8.0/bin/octave-3.8.0", "$file"],
"selector": "source.m"
}
Save it as Octave.sublime-build
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.