Weird question about the editor...

So this might be insanely daft of me to ask...
But most of my code writing takes place in the editor. When writing code/copy pasting stuff into a code comment I can't help but notice that thin line that runs veritcally down in the editor, over about 1/3 of the total lenth of the screen to the right of the code. What is this line? Why does it sometimes word-wrap my comments when it touches the line, and sometimes doesnt? Just a curious cat meowing into the midnight under the moonlight.

8 comentarios

Stephen23
Stephen23 el 9 de Mzo. de 2024
Editada: Stephen23 el 9 de Mzo. de 2024
"What is this line?"
Aaaaaaah, to understand that right-hand text limit (as it is called in the MATLAB settings) you have to delve into the history of computers. In short, it is because a long time ago computers could only hold/process/print a limited number of characters per line (limited by various technologies):
You can find more detailed history of this line online.
Programmers hold onto that line like a kind of comfort blanket, even though any technical neccessity it might once have had has been irrelevant for more than half a century. Feel free to ignore the line if you want (or change its placement in the settings), with the understanding that programmers are very delicate creatures and are easily surprised by small changes in what they see (in your code, in other languages, etc) and will let you know that you are doing something very very wrong... but are not really able to state exactly what.
Perhaps some of them will reply here.
Spaceman
Spaceman el 10 de Mzo. de 2024
What do you have yours set to, by chance?
Stephen23
Stephen23 el 10 de Mzo. de 2024
"What do you have yours set to, by chance?"
The default... and I ignore it whenever I wish to.
The modern argument in favor of such a limit is that code lines above a certain length are harder for humans to parse and understand (and hence increase risk of bugs, etc). There is a certain truth to this, but in my experience that length depends highly on the content of that line, the content of adjacent lines, what kind of syntax is being used, etc. Thus out of many years practice I learn to use that limit as a guide but have no qualms about having shorter/longer lines when the context makes that an aesthetically better decision.
Spaceman
Spaceman el 14 de Mzo. de 2024
Thank you. Doesn't the right handed text limit "cutting" right into your line of code, or more commonly, comment, drive you batty as it does me?
DGM
DGM el 14 de Mzo. de 2024
Why wait for the cat to step on the keyboard when you can let your IDE spontaneously slap a newline in the middle of what you're typing? With our advanced settings, the right-hand text limit is no longer just a mostly useless distraction, it can now double as a recurring nuisance! Brilliant!
I disabled everything related to the text limit.
Spaceman
Spaceman el 21 de Mzo. de 2024
Yes, I have mine set such that it is so far away it's basically at the limit of my editor and I don't have to worry about it as much until I upgrade to a bigger laptop.I just like to see people's preferences, and why. That's what's so amazing about the world and the people in it.
DGM
DGM el 21 de Mzo. de 2024
To be fair, I've changed my formatting style a number of times over the years, but I never fail to think that I've got it nailed down tight. It's almost like I don't know what I'm doing. :)
Spaceman
Spaceman el 8 de Abr. de 2024
What do you mostly use MATLAB for?

Iniciar sesión para comentar.

 Respuesta aceptada

the cyclist
the cyclist el 9 de Mzo. de 2024

1 voto

The line you are talking about is referred to as the "right-hand text limit". You can adjust some properties for it under MATLAB -> Settings -> Editor/Debugger -> Display. As I recall that line is just a visual reference, with no impact on wrapping.
There is also "Comment Formatting" under MATLAB -> Settings -> Editor/Debugger -> Language. That does affect wrapping. (It is a bit smart in that it won't split words in half, etc.)
I believe these are both set to 75 initially, but you can set them independently.

3 comentarios

Spaceman
Spaceman el 10 de Mzo. de 2024
What do you have yours set to by chance?
the cyclist
the cyclist el 10 de Mzo. de 2024
I have the "Display" value at 125, and the "Language" setting at 75. I can't remember if those are just the default, or I changed them.
Spaceman
Spaceman el 14 de Mzo. de 2024
I believe the default for the line is 75. I set mine to 100 columns as it seems to be more "out of my way". I only notice the issue of it not wrapping properly when I copy and paste something into my functions of scripts; There is probably a setting to fix that, of which I will never know.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Entering Commands en Centro de ayuda y File Exchange.

Productos

Versión

R2023b

Etiquetas

Preguntada:

el 9 de Mzo. de 2024

Comentada:

el 8 de Abr. de 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by