Wednesday, January 14, 2015

Toggle comment blocks with 1 character

IDEs that allow you block comment and uncomment seconds with a keystroke are awesome. Only problem is many IDEs have different keyboard combinations for this, and many times you may be working in a simple text editor for quick code.  I often disable chunks of code and never liked the amount of typing I would have to do. I developed a commenting style that works on any language that uses "//" for line comments and "/**/" for block comments.


The Basic Block

This will toggle a single block of code by adding 1 "/" to the first line

/* comment about block of code
inactive block of code
//*/


//* only line change is here
active code
//*/


You can toggle blocks by introducing a "/*/"


/* only line change is here
inactive
/*/
int active
//*/


//* only line change is here
int active
/*/
inactive
//*/
I have more examples here

GIF example:

0 comments:

Post a Comment