# Is there any way to align both codes and comments?

a=4;          (*length*)
b=5;          (*width*)
s=a*b;        (*area*)


Is there any way to align the code above left and also align the comments? Now it looks good because I add some space before (**). However, when I change the code, such as below, I need to add or delete some space. This is not what I want.

a=400;          (*length*)
b=50;          (*width*)
p=a*b+a+b;        (*coment*)


There is a function called \[AlignmentMarker]. It only alines the comments, but not the code:

a=400;          \[AlignmentMarker](*length*)
b=5;          \[AlignmentMarker](*width*)
s=a*b+a+b;        \[AlignmentMarker](*area*)


Is there any better way?

• one option would be to use code cell instead on input cell. Then you can align things manually as you want without having the notebook automatic formatting be involved. – Nasser Jan 15 '19 at 3:52
• How general it should be? Do you want to automatically allign them for readability or to have them aligned 'live' as you type? What if the code is longer than the page or window width, etc etc. – Kuba Jan 15 '19 at 23:45