I realize this isn’t the ideal solution for folding a random chunk of code, but it’s a reasonable workaround in the meantime.
By
Ken Orr
Ken is a developer on the MATLAB Desktop team. He loves the art of graphic design as well as developing visually pleasing user interfaces - he's one of those 'crazy' Mac guys!
I’ve always used folding in vim with the markers
%%FOLDUP
and
%%UNFOLD
I think code sharing would be much easier if there were a single standard, such as this one, which could be used in one’s editor of choice (including the matlab editor) and which persisted with the ascii file…
Hi Steven,
Do you typically want your folds to be shared with other users? It seems that I’d want to remove folds before submitting or sharing code.
-Ken
Hi,
I am sorry if this is off topic.
But I find something very annoying in Matlab. The way matlab command history window displays, always “expanded”. Is there any way to set that it is always “collapsed”. It’s very tedious to scroll through it to a specific command in specific date. If it were always “collapsed” then I could go to specific date and expand it to see the list of command on that date.
Hi Suresh,
Thanks for the feedback. Note that you can start typing a command in the Command Window and up arrow, which will then cycle through only the commands starting with what you’ve typed. I use this technique all the time to find previously typed commands.
-Ken
Hi,
I’d love to do code folding! BUT, even after using cells in the code and enabling code folding in the preferences menu, there are no +/- signs to click on anywhere in my code to enable code folding.
I’m writing a script .m file(not a function) and running:
MATLAB Version 7.5.0.342 (R2007b)
Also, I have cell highlighting on and it highlights correctly so I know that my cells are correct and the editor recognizes when my cursor is in one.
Is this a version issue?
thanks!
Hi, Alexander here again,
After a little research I found that when I try to code-fold manually by right-clicking and going to the code-folding option, all 4 options are grayed out and cannot be clicked on. Also, enabling/disabling code folding I noticed that when it is enabled my code is shifted over ~5pixels to, ostensibly, make room for the +/- graphics to be clicked on. However, as I mentioned before, there are no such signs.
Also,I should probably mention that I am running this on a Windows XP 64bit architecture.
doubly thanks,
-alex
Alexander,
Only functions were foldable in R2007b. Code folding for cells was added in R2008a.
Thanks Mike, I’m downloading R2009b as we speak!