How to do better commenting in Matlab script?

When I am trying to comment long sentence in script, it unnecessarily to next line. But, I want to continue in the same line. Probably, that's because of grey shaded line as shown in figure. How to move this vertical line, or slide it in a place where I want. Thanks

6 Comments

Not positive about the wrapping; I don't see the behavior here with R2012b.
The line position/visibility is controlled under Editor Preferences (Editor, under Preferences under the big "Environment" button in IDE) under Display. There's a section "Comment Formatting" under "Language" that has a checkbox for wrapping comments automagically. I note it is in the default checked position here but I don't seem to get any unwanted linewrapping even with the default(? I don't recall changing it, but may have) 75-column position. Again this is R2012b and perhaps it isn't functional but has been made so in a later release?
Anyway, mess around with those properties/preferences and see it it fixes up the problem.
Might let us know which release...
From the screenshot titlebar we can see it's 14b.
If you can read that you've either got much better eyes than mine or a HUGE monitor... :)
You can right-click over the image and ask your web browser to view the image to see a larger version of it.
Of course one can (^+ is simpler)
Click anywhere inside the comment and hit ctrl-J. This will force the comment to wrap to the margins. This is one of my favorite keyboard shortcuts.
Automatic wrapping of long comments as you type them has always seemed hit-or-miss; sometimes it works, other times not so much.

Sign in to comment.

Answers (2)

You'll get to the settings you need under "Home -> Preferences -> Editor/Debugger -> Display" and "Home -> Preferences -> Editor/Debugger -> Language"

3 Comments

So, Ken, I'd never paid any attention before is this a "feature" that was introduced but just doesn't seem to work in R2012b or is there some other "trick" that causes it to occur? As noted, I've got column 75 and the "wrap" is checked but I don't see anything happening automagically to comments when they go past...
"Enquiring minds" and all that... :)
It's been there a while. But the confusing part is that it's really in two places in the preferences. You also have to look in the Language screen:
&nbsp
&nbsp
Set it high here if you want to manually control your own line wrapping. I set my values high on both screens because I want to control my own wrapping (sick of having comments with only one word on the second line and then having to manually delete end of line and comment symbol to make it all on one line.) dpb, you might try setting the value on this screen as well as the display screen to achieve whatever you want.
Yeah, I found that in research the question -- the thing I discovered is and was wondering about is that it is still at the (I presume default?) column 75 and the language section "Wrap" box is checked but I still see no automagic (and like you, that would be undesirable behavior) wrapping occurring; hence
  1. I'd never noticed it; the line is so faint as to be indiscernible unless I really look for it so actually hadn't ever noticed it was actually there and
  2. thus the query about whether it is/was simply a nonfunctioning function yet to be implemented in R2012b but for which the UI hooks had been implemented. Although this seems not likely as I see on looking that R14, the latest previous release prior to R2012b installed, has the same options so it's been around a while.
So, I'm still confused as to the behavior -- I'm happy it doesn't futz with my files but curious as to why not given the settings as are...
Which reminds me of my earlier query that got no response on file extensions and language support...
Customization of editor: Add a language and or extension which puzzled me greatly that nobody had even a comment on the subject, what more an answer...

Sign in to comment.

Tanmoy, (in R2015a) go to Preferences > Editor/Debugger > Display. In the Right-hand text limit section you can remove that line or move it to wherever you want using the Placement field.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Asked:

on 13 Jun 2015

Commented:

Jim
on 19 Jun 2017

Community Treasure Hunt

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

Start Hunting!