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

Stephen23
Stephen23 2024년 3월 9일
편집: Stephen23 2024년 3월 9일
"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 2024년 3월 10일
What do you have yours set to, by chance?
Stephen23
Stephen23 2024년 3월 10일
"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 2024년 3월 14일
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 2024년 3월 14일
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 2024년 3월 21일
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 2024년 3월 21일
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 2024년 4월 8일
What do you mostly use MATLAB for?

댓글을 달려면 로그인하십시오.

 채택된 답변

the cyclist
the cyclist 2024년 3월 9일

1 개 추천

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

Spaceman
Spaceman 2024년 3월 10일
What do you have yours set to by chance?
the cyclist
the cyclist 2024년 3월 10일
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 2024년 3월 14일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

제품

릴리스

R2023b

태그

질문:

2024년 3월 9일

댓글:

2024년 4월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by