Is there a way to set side comments to hold indent amount?
22 views (last 30 days)
Show older comments
This is a fairly small thing but bugs me nonetheless. For example I have this base section of code that I've written where I input my variables:
%%input our givens... unknowns get nan's:
p1 = 12*10^3; %W
q1 = 6.667*10^3; %var
s1 = nan; %VA
theta1 = nan; %degrees
pf1 = nan; % "-" means lagging
The values in this particular section of code end up getting changed a lot so the comments/labels on the right hand side get all out of alignment, like this:
p2 = nan; %W
q2 = nan; %var
s2 = 4*10^3; %VA
theta2 = nan; %degrees
pf2 = 0.96; % "+" means leading
Is there a way to set a indent length or perhaps a second column in the Live Editor so that my labels on the right hand side stay nicely lined up like the first section of code? For now I've been re-aligning manually but it would be nice if there were a way to set it to be done automatically.
0 Comments
Answers (1)
Image Analyst
on 22 Sep 2021
You're using tabs before the %, not spaces, right? Because that will align them but of course if you make changes to the length of the code line more than a tab, it will "jump" to the next tab. But at least they'll be aligned to the nearest tab column.
Make sure your preferences are not setup to insert spaces when you type a tab.
Home->Preferences->Editor/debugger->Tab-> Uncheck "Tab key inserts spaces".
0 Comments
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!