Where developers come to connect, share, build and be inspired.

21

The //* /*/ //*/ comment toggle trick

99306 views


DISCLAIMER: This is a trick. Do not adopt this trick in production code. Use it wisely while you're doing proof of concept and the like.

So, I guess I'm not the only one that need some way of easily toggling code in and out of the code.

This trick below can be used to toggle between two sets of code, with one symbol in the code with no additional short-keys to learn, and no tool dependencies!

//*                      /*
someCode();              someCode();
/*/                      /*/
someOtherCode();         someOtherCode();
//*/                     //*/

Here is a version for simply commenting code in and out:

Activated:

//*
someCode();
//*/

Deactivated / commented out:

/*
someCode();
//*/

Comments

Add a comment