MATLAB: Automatically align comments to the right hand side of the editor

editortext;

Hello here
Does anybody has a workaround whereby you can automatically align the comments inserted after the code to the right hand side of the text editor? To clarify, something like
if called % first comment aligned to the right
do this
else % second comment aligned too
do nothing
end % need to align automatically
Any ideas? Many thanks

Best Answer

I had the same issue, I modified the code from Alessandro Masullo to do the task (attached). I know it's an old question, but it will be maybe useful in the future :)
Related Question