Matlab Utilities for Mac OS X

Matlab Language Module for BBEdit and TextWrangler

Matlab Language Module is a language module plug-in for BBEdit 11 and TextWrangler. It provides basic syntax-higlighting and function menu instructions to BBEdit/Textwrangler. Version 2.4 supports folding of functions, but version 2.3 does not.

Download

Installation

Unarchive the module using the Finder. The module plug-in is called "Matlab.bblm". Quit BBEdit or TextWrangler if it is open, and place the module in "Applicaton Support/BBEdit/Language Modules" or "Applicaton Support/TextWrangler/Language Modules" folder under your Library folder. (If the folder "Language Modules" does not exist in these locations, simply create a folder of that name there.) You may need to remove the .m suffix mapping for Objective-C in the BBEdit Preferences under Languages to get the Matlab module to work properly. (See the Notes below.)

Source Code

Notes

2014-11-15: Version 2.4 of the plugin works with BBEdit 11. Older versions of the plugin do not work with BBEdit 11. Version 2.4 will not work with older versions of BBEdit nor with TextWrangler. Version 2.4 adds some language specific color settings in the BBEdit Text Colors preference panel. This version also adds support for code folding of entire functions. Default line and block comment characters are now set by the plugin so you won't have to set them manually.

Under Mountain Lion (the new OS version) executable files won't run unless they are authored by a developer with an Apple Development ID. The code has to be signed or, under the default settings, the OS kicks it out and won't let it run. So BBEdit recognizes the plugin but can't load your executable file.

The quick fix for users is to go to the "Matlab" executable in the Matlab.bblm package (Matlab.bblm/Contents/MacOS/Matlab), right click on it and choose open, then tell the OS that its OK to run the executable. Note that you must right click. Double clicking does not work. After that, it will run fine with no intervention.

Thanks Tom

2012-03-06: A number of people have contacted me asking if the plugin still works in BBEdit 10. I have tried it and it does work for me. Things to check:

Make sure the plugin is installed. In the Preferences panel, go to "Languages", and click the "+" button below the "Custom Language Preferences" box. In the popup menu, you should see "Matlab". If not then the plugin is not installed. Install using the above instructions. (As an aside, if you add "Custom Language Preferences" for "Matlab", you can assign "%" as the line comment character so that "Comment/Uncomment" in the "Text" menu will work properly.)

Make sure other plugins are not using ".m" as an Extension Mapping. In older versions, one used to be able to remove extension mappings for built-in languages. This ability appears to have been removed. From what I can tell, extension mappings for plugins take precedence over built-in languages. You could try adding ".m" as a custom extension mapping for "Matlab" and see if this helps.

Use the status bar to see what language BBEdit thinks your file is written in. The status bar can display the language of the file. If your status bar does not show this, go to the Preferences panel and choose "Appearance" and check the box to show the language. The status bar can be used to explicitly set the language on a per-file basis.

2006-06-25: I've changed the archive format from sitx to zip for the above links. If you would rather use Stuffit Expander, you can get the version 2.2 as sitx here.

2006-02-11: I was able to test the universal binary version of the language module on an Intel-based iMac with Text Wrangler and it works fine.

2006-02-08: UPDATE The above link is updated to Version 2.2 of the Language module. I was informed that Matlab 7 supports block comments using the delmiters '%{' and '%}'. Version 2.2 of the language module supports the block comments, and they are colored the same as line comments. The delmiters must appear on lines containing the delimiter and nothing else but whitespace. Block comments may nest. For example:

is a valid nested block comment. If any other characters appear on the lines containing the delmiters, the delimiters turn into ordinary line comment markers. Version 2.2 is a universal binary. Keep in mind that using block comments will make your code incompatible with older versions of Matlab. Block comments are not very necessary anyway since most text editors, including BBEdit/TextWrangler, can easily apply and remove line comments to ranges of text.

2006-01-13: UPDATE The above link now points to Version 2.1 of the Language module. The only change is that the plugin has now been built as a universal binary. I have not tested it on an Intel based Mac. Send me an email if you have any problems with it.

2005-09-12: UPDATE The above link now points to Version 2.0 of the Language module. This new version is a bundle built with Xcode and requires BBEdit 8.0 and higher or TextWrangler 2.0 and higher. You can get the previous version (1.0.2) of the plug-in here.

New in version 2.0:

Continuation characters '...' are colored the same as keywords, and all text following '...' is colored the same as comments to the end of the line.

System commands that follow an '!' are now colored. This color may be set using the 'Processing Instructions' button in the 'Text Colors' preference panel in BBEdit.

The color of uncompleted character strings can be set using the 'Image' button in the 'Text Colors' preference panel.

Also, keywords that are used as members of structures are now not colored as keywords. For example a structure might have a member called 'function'. It would be normal for references to this member such as my_struct.function to not have any coloration on the word 'function'. Also, when 'end' is used as an index to an array such as my_array(1:end) it will now not be colored. In fact, keywords will only be colored if they appear in their proper context as matlab flow control statements.

The function popup menu will now position the cursor at the start of any comments that precede the start of the function definition.

Newer versions of matlab allow functions to be nested if they are terminated by 'end' statements. The function popup menu indents nested function names accordingly.

2005-06-22: BBEdit 8.2.2 has fixed the syntax coloring for compiled language modules. The matlab module should work normally now.

2005-05-11: BBEdit 8.2.1 appears to have broken the syntax coloring in the matlab module. The function popup appears to be unaffected, and built in languages also appear to work normally. I have contacted BareBones and they are aware of the problem. The bug affects compiled language modules. I assume this will be fixed in the next update to BBEdit.

2004-08-30: The Matlab module should work with BBEdit 8.0. Users should be aware that language modules are now installed in BBEdit's ApplicationSupport folder located in the user's Library folder or in the global /Library folder. For example: /Users/<your user name>/Library/ApplicationSupport/BBEdit/LanguageModules/
is where language modules should be installed.
Also there is new support for what Barebones calls "Codeless Language Modules" presumably for providing a simple way to add new languages using plist files. One could create a matlab module using plists, but there is not much flexibility for handling function definitions nor can the plist distinguish between string delimiters and the matlab transpose operator.

2004-03-29: UPDATE: Matlab Language Module versions 1.0.1 and 1.0.0 don't support Unicode and will not work with BBEdit 7.1.3 or higher. The above link has been updated to 1.0.2 which supports Unicode and will work in the new version of BBEdit. Sorry for any inconvenience.

2002-11-12: I've updated the matlab language module at the above link to version 1.0.1. This version fixes a small bug that caused incorrect syntax coloring of the transpose operator when following a decimal point. If you find any bugs in the module feel free to send me an email about it.

Old Stuff

CMD_Matlab is an applescript that launches Matlab 6.5 for Mac OS X command line mode. This is useful for Jaguar users since the Jaguar release of Mac OS X broke the graphical interface to Matlab 6.5. CMD_Matlab first starts the OroborOSX window manager and then launches matlab in the Terminal. This only works on Mac OS X 10.2. Source is included incase you need to change reference to OroborOSX.

Note: A Matlab patch was released back in mid October 2002 that fixes problems with Jaguar. Go to Mathworks for the updater.

2003-01-10: Mathworks has released a replacement script to make LaunchMATLAB work with Apple's X11. See http://www.mathworks.com/support/solutions/data/33869.shtml for details. (1/13/03 Mathworks appears to have removed this page) You'll need to make it executable and open the package contents of LaunchMATLAB and copy it there. Be sure to make a backup of the old script.
Here's a stuffed copy of LaunchMATLAB with the replacement script in it. You'll need to put this in the bin folder in your Matlab installation folder for it to work.

2004-03-05: If you use Mac OS X 10.3 (Panther) or higher, you need to run Matlab 6.5.1 with Apple X11 1.0. The LaunchMATLAB app that comes with the 6.5.1 update from Mathworks launches X11 and not OroborOSX. I have not tested any of the above downloads with Panther.