Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to comment out a block of code that already has multiple line comments?

Tags:

javascript

Is there a way to do something like this in Javascript?

/*
    code
    /* Multiple
    line
    comment */
    more code
*/

When I test, I often need to comment out large chunks of code that already have multiline comments.

like image 324
Arthur Tarasov Avatar asked Oct 04 '16 08:10

Arthur Tarasov


3 Answers

I think your IDE have find and replace option.

Add /* at starting and */ at ending

Within the code block

Replace */ with *//*

then to if you want to remove the comments you made :

Remove /* at starting, Remove */ at ending

Within the code block

Replace *//* with */

like image 159
Rohith K N Avatar answered Oct 25 '22 05:10

Rohith K N


This is not a direct answer, per-se. But the fact that block comments can't also block nested comments is a horrifically lame situation to begin with. The answer is to fix JS.

The obvious rule: EVERYTHING between the comment tags is to be treated as a comment. Period. To re-interpret commented text as functional in any way is just not sane. Commented text should not have any functional symbology.... it should not be getting parsed at all.... no excuses. Commented text should be absolutely dead. Non-funcitonal.

like image 33
ryder Avatar answered Oct 25 '22 04:10

ryder


In VS studio I was able to highlight the lines of code and use 'ctrl + /' and it toggles the lines of code to either be commented out or back in. Hope this helps!

like image 39
ReallyImOneOh Avatar answered Oct 25 '22 05:10

ReallyImOneOh