There are a couple of features available in the editor in R2010b that I take full advantage of. Variable highlighting is one, and comment wrapping is the second.
There are two aspects to variable highlighting that are available in the editor in R2010b. The first is that if you select a variable, all other instances of that variable get highlighted and a summary of the usage appears in the status bar and the lines where these appear show up on the information bar on the right-hand side (where code analyzer messages also appear).
The other highlights that you can see are for nonlocal variables, i.e., variables shared between a parent function and a function nested in it.
You can turn these highlights on and off and change the highlight colors in the MATLAB preferences. Mike talks more about variable highlighting in this post, as well as showing pictures.
Since I produce my blog by writing MATLAB code in the editor, I find myself frequently editing and having some lines very long, and some unnecessarily short. I used to have to select an entire region and rewrap the comments. Now I only have to have my cursor in that region, and with the stroke of Ctrl-J, I get them nicely wrapped. Jared talks more about this in his first post.
In his second post, Jared talks more working with indented code and wrapping associated comments. In addition, block comments now wrap appropriately as well.
Any comments on managing comments in MATLAB code? Let me know here.
Get the MATLAB code
Published with MATLAB® 7.11
Comments are closed.
6 CommentsOldest to Newest
Nice enhancements to the editor. I think i will especially find the var-highlighting useful.
—- Sorry if this is off topic —-
One thing that bugs me is the non-local variables/nested functions. There are many cases where i would really like to use them, but then i debugging becomes a pain. -if you use a non-local variable then you are not allowed to create new vars in the matlab debug prompt.
Syntax-wise I think it is non-intuitive with the present scoping rules in nested functions. I would have preferred an explicit scope declaration rather than having to choose between all variables or nothing being shared with sub-functions. (I guess it would also have made the above debugging problem a non-issue.)
I do like the variable highlighting.
Unfortunately the summary in the status bar does not update when moving the cursor to another variable. I will have to “force refresh” by for example moving the mouse over one of the tabs, then the status bar says “Click and drag to …”. Then the next move to a variable will display the summary of that.
Is this a common feature or is it my computer only?
You are right – this is a known issue in R2010b and we have fixed it in an upcoming release. Besides the workaround you described, you can also navigate to the next variable with your keyboard to refresh the status bar.
Any chance the editor ever gets released on its own, with context-highlighting for various languages? The matlab editor is by far my favorite, but I can only use it properly for matlab code :(. It would be great if it were available as a standalone product, as it seems to be semi-divorced from matlab anyways.
Thanks for the positive note about the Editor. No plans currently to make it a separate component, but it does already support syntax highlighting for a variety of languages (XML/HTML, C/C++, Java, VHDL/Verilog). Are you looking for something else, or just the ability to use it independent of the rest of MATLAB?
@Jared – while syntax highlighting for some other languages is indeed supported, this is not so for other editor functionality. For example, the functions drop-down button on the toolbar only works for Matlab m-files. It would be great if the ML editor also had these functionalities available for the other languages.