MATLAB Community

MATLAB, community & more

Fold whatever you want using cells

Juliette recently suggested that users should be able to fold whatever code they like. While this is a great feature idea, the MATLAB Editor doesn’t currently support folding arbitrary sections of code. You can, however, simulate the feature using cells.

Start by turing on Cell folding in Preferences -> Editor/Debugger -> Code Folding (folding cells is off by default). Now, take your raw code, which we’ll say looks like this:

and insert cell markers before and after the code you want to fold, like this:

Finally, collapse the cell and voila! You’ve folded an arbitrary chunk of code!

I realize this isn’t the ideal solution for folding a random chunk of code, but it’s a reasonable workaround in the meantime.



To leave a comment, please click here to sign in to your MathWorks Account or create a new one.