Developing a toggle to Hide/Show comments

Comments are hardly ever needed during development and being able to hide them would:

  • Enable you to display more lines of code and increase productivity
  • Allow free style and personal comments to be inserted
  • Reduce the scope of separate technical documentation
  • Better inline documentation would save time when revisiting the code later.
  • Enable you to distribute undocumented code to keep some techniques proprietary
  • Having the frame work it would allow users to add other auto-formatting tools

This may actually be a very old feature request but I would like to try solving this myself using afl.

  1. Since we cannot add a custom item to the editor menu we could use the Parameter Window to toggle comments ON a OFF.
  2. When Hiding comments we would save a backup copy of the file and remove all /* … */ comments while leaving the // comments in place as these are often single lines used to separate sections of code.
  3. The Parameter toggle would swap the two files in the editor window.

The big problem is how to reload the afl formula after each toggle and how to ensure the full version is saved on exit.

Perhaps there is an easier way to do this?
Does anyone have any ideas or suggestions?

Thanks!
Herman

The code should be written so it is self-explanatory. If you use self-explaining variable names
and function names the code will become crystal-clear without lots of comments. Still if you need comment folding, you can use code folding. Comments alone do not fold, but you can put empty block statement and it will allow folding

{
/* This comment will fold in the editor
** 
**
**/
}

I can add C-style comment folding /* ... */ without those parentheses in 6.26

2 Likes

Thank you Tomasz,

Folding All is a nice feature but it also hides most of the code and makes
it unreadable. It doesn’t solve all my requirements.

I probably use the longest and most descriptive variable names on the forum
:slight_smile: but we all have our own style of coding (which to a large extend depends
on programming expertise) and the level of commenting also depends on the
target audience.

My question remains on how afl files can be swapped and reloaded - besides
doing this manually of course.

best regards,
Herman

But you can just fold the comments! Each fold section has separate square button that allows to fold/unfold each section.

re: I can add C-style comment folding / … / without those parentheses
in 6.26

If that would then only fold the /* … */ comments and leave the functions
unfolded, that would be nice…but would it then hide comments inside
functions?

But this is a minor convenience item and I wouldn’t want you to spend a lot
of time on this…but thanks for considering it.

Herman