Option to hide comments

It would be fantastic if there was a view option we could toggle which would hide all // and /**/ comment text.

Sometimes there are blocks of code that I plan to deploy at a later stage, being able to code them now, but hide them would be a nice workflow improvement.

Any thoughts? :smiley:

All the best,
Dax.

A better workflow arrangement might be to fold the the code into comments, so the comments remain visible, but not the code.
The first time I came across this approach was in the mid-80s using the Inmos Transputer Development System (TDS), but many IDEs now implement code folding.

I wouldn't sat that's the best option for something that looks like this, though:

Well, if the code matched the comment (the very first comment) I wouldn't have quite so much of a problem. . .

If you want to remove code, don't use comments, use the preprocessor.

As does the Arduino IDE

Try this:

  1. Select File > Preferences from the Arduino IDE's menus.
  2. Check Enable Code Folding
  3. Click the OK button.
  4. Right click on the IDE's editor pane.
  5. Select "Folding" from the context menu.
  6. Select "Collapse all comments" from the "Folding" menu.

This only works for the block comments, but it is close to what you asked for.

You can control it on a per-comment basis by clicking the little - icon on the left margin of the IDE's editor pane at the start of a block comment.

That is for version 1.13 etc. It actually works very well in version 1.

Version 2 does have folding but it is not great. It seems to only fold till it hits anything in the first column (eg #, //, */ ). That makes it almost unusable. You cannot fold a full function with anything in the first column anywhere.

Willem.

I had a thought for a quick workaround, is there a way to toggle (without restart) the text colour of comments? I figure it could be made the same as the background colour at least.

Interesting @in0 , I had this enabled on another PC, but here I don't have the option:

Folding is always enabled in IDE Ver 2.

If you move the cursor into the open column between the line numbers and the vertical code start line, down arrows appear next to foldable text. Click the arrow to fold, it turns to an arrow pointing right. Click again and the code unfolds.

Willem

Thanks @Willem43 , but I could swear that I was seeing [-] icons last week..?

In version 1, yes.

Willem

1 Like

Have you fixed the code/comment yet?

Hey Shannon, what needed to be fixed? Do you mean two comments on the one line? That's intentional. The line itself is commented out and the second comment is the comment as to why that line is commented out.

Shannon?
He's dead, isn't he?

The comment doesn't match what the code is doing.

In version 1, yes.

Ahh, yes, so it does.

Oooohkay, @TheMemberFormerlyKnownAsAWOL. Yes, you are techincally correct that the exact line is not averaging 100 readings, it is indeed just adding 100 readings together to be divided by 100 just outside of the loop. (I don't know of a better way to do that.)

Am I being dense or are you being pedantic?

Either way, this post is not about my code, but a way to improve the UI/UX.

Cheers,
Dax.

No, I am absolutely correct that you're adding 101 readings, and dividing by 100.

Well, I didn't like to say as much...

Try ctrl + k followed by ctrl + /. That folds all comment blocks (well, most of them).
ctrl + k followed by ctrl + j unfolds everything.

Press F1 then search for Open Keyboard Shortcuts. It opens a new tab. In the tab search for folding to see all the folding options. Definitely not the most intuitive.

Willem

1 Like

@TheMemberFormerlyKnownAsAWOL Dude, for real? Are you suggesting that changing the comment from "100" to "101" will fix the actual topic of this post? Obviously not. Please don't be a pedant. If you want to point out a mistake in someone's code, just point it out. Don't be an arse about it, especially when the code doesn't affect the issue at hand.

Incidentally, I snipped that section of code from an example I found online.