Does anyone know of an existing method of automatically cleaning the indentation of a MATLAB/Octave script? I've got someone else's code (no, really!), and it's horrible - none of the loops or functions are indented, and half of the other lines are indented to apparently random depths.
The problem with MATLAB is that it doesn't use braces, so C++ style indenters aren't going to work. Python ones might, with a bit of modification, which I will try if I can't find a pre-existing solution.
Basically it'd just need to indent lines after lines starting with function
, for
, if
, while
... and un-indent lines starting with end*
, I think...
Clarification: As pointed out by Jonas, MATLAB users can just select all, and ctrl+I
to nicify the indentation. Unfortunately, I don't have access to the MATLAB editor, and it would also be nice to be able to auto-indent a batch of files all at once.
CTRL+A
(to select all), followed by CTRL+I
(to automatically indent) will do the trick in the Matlab editor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With