davidvarga / MBeautifier

MBeautifier is a MATLAB source code formatter, beautifier. It can be used directly in the MATLAB Editor and it is configurable.
GNU General Public License v3.0
478 stars 75 forks source link

Align assignments at the "=" sign #104

Closed plkinon closed 2 years ago

plkinon commented 3 years ago

Dear contributors,

I am happily using MBeautifier! Just one thing strikes me: I want to align assignments at the "=" sign to make code more readible, e.g.

Variable1 = 1;
str       = 'Hello!';

Is this currently possible to do? If not, would it be easily implemented?

Bests Philipp

davidvarga commented 2 years ago

Hi!

It is nearly impossible to do with the current implementation, but if you formatted the lines once, MBeautify can be instructed to skip the formatting for a section using Directives: https://github.com/davidvarga/MBeautifier#directives

In you example:

% MBeautifierDirective:Format:Off
Variable1 = 1;
str       = 'Hello!';
% MBeautifierDirective:Format:On

will instruct MBeautifier to disable formatting for that section in the code.

I hope this help! :)

plkinon commented 2 years ago

Hi!

Yes I saw this in the Readme file but those extra comments are not what I want, too.

Nevertheless: Thank you!