Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automated indentation cleaner for MATLAB or Octave? [closed]

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.

like image 449
naught101 Avatar asked Jan 28 '11 01:01

naught101


1 Answers

CTRL+A (to select all), followed by CTRL+I (to automatically indent) will do the trick in the Matlab editor.

like image 127
Jonas Avatar answered Nov 16 '22 04:11

Jonas