Color coding commented statements and comments following a statement
Mostra commenti meno recenti
Hi,
I would like to know if there is a possibility of having a different color for a commented statement and a comment that follows a statement, e.g.,
% u=rand
u = rand % generate a random number from U[0,1]
shows both in green but I would like to differentiate. I could not find a lead from MATLAB preferences.
9 Commenti
Steven Lord
il 21 Ago 2019
Modificato: Steven Lord
il 21 Ago 2019
I'm curious why you want to see those two comments colored differently. How would distinguishing those two cases be useful for your workflow?
I'm not just asking this of the original poster from back in 2015; anyone who's commented since then, I'd be curious about your answer to that question.
Stephen Cooke
il 10 Nov 2019
I came upon this thread hoping to change comment color. The project I am currently working involves interpreting and commenting on matlab code written by someone else. Commenting in multiple colors would come in handy for me because I would be able to flag lines of code that I need to work on at a later point by giving the comment a different color. This would allow me to quickly identify relevant lines of code when I return to my work.
John D'Errico
il 10 Nov 2019
Stephen makes a good point, of a case where it would be useful to explicitly set comment color differently on demand.
For example, when I am writing code that will require several days or more to write, I often insert a garbage line in the code where I stop for the day, just random characters on the keyboard.
245y2562y4uy6
This way, if I tried to excute the code, it will fail, and it is obvious where I left off. Better would be to have a comment in RED perhaps, that would be a strong visual flag to draw my eye to the spot. And since it is a comment, I can note exactly what needs to be done in that missing block of code.
I can even see multi-colored comments as useful when code is shared between multiple people who are co-authoring the code.
But personally, I can see essentially no purpose in having MATLAB automatically differentiate comment color based on where the comment lies, thus an inline comment versus a stand alone comment.
Steven Lord
il 11 Nov 2019
That seems like a reasonable use case for having comments in multiple colors. Right now all comments are a single color, though you can change that color in the Preferences. I recommend sending this to Technical Support as an enhancement request, so it gets captured in the enhancement database.
There is some functionality that may help you identify work that needs to be done (by who needs to do that work or for which step of your project the work needs to be completed.) The TODO/FIXME report available from the Current Folder browser will let you search for specific identifiers (TODO, FIXME, or "Fix:Stephen".)
If you're going to leave the file open in your MATLAB session but need a "pick up from here" marker (say if you're going home for the night) you can set bookmarks in the file (see the "Set Bookmarks" item under the "Go To Location in File" section on that page.)
Matias Oddo
il 13 Mag 2020
Commenting to follow this thread.
Perhaps the # symbol could work as a clone of % but in a different color. That would be simple and mighty useful!
Will Graber
il 11 Giu 2021
Commenting just because I would still love to see this feature and am also going to send a support email too.
Thomas Fiedler
il 23 Dic 2021
the feature is interesting to differentiate my comments from other peoples comments
olshie
il 28 Feb 2022
It would be great to differentiate comment colors with flags: for example
%todo: do this later
would appear in a different color.
Gionata Quadri
il 13 Mag 2022
A small workaround could be to write the "comments" (e.g. todo) as a system command with the bash colon operator ':', and temporarily change their color in the settings.
s = settings;
s.matlab.colors.SystemCommandColor.TemporaryValue = [255 75 0];
!: TODO: Lorem ipsum
Unfortunately it only works on new lines.
Risposte (5)
Michal Demjan
il 21 Ago 2019
2 voti
Also interested!
Maybe just implement different commenting function starting with '%!' or something..
mbvoyager
il 24 Ago 2018
1 voto
I'm also interested in this feature!
Francesco Guaresi
il 4 Dic 2018
1 voto
Hi guys! I'm interested too!!
Eli
il 7 Lug 2022
0 voti
I would also like more customizability for organizing code (like changing colors of comments)!
mohand alzuhiri
il 25 Ott 2022
0 voti
It would be nice to have a special color for ToDo items...This feature would be useful especially when you want to share them with your team
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!