Double-Slash-Whole-Block-Commenting
Here is a simple way to disable or enable whole code blocks with just two slashes:
PHP / C++:
/* Block (commented block) //*/
///* Block (active block) //*/
Object Pascal/Delphi:
(* Block (commented block) //*)
//(* Block (active block) //*)
Alternatively you can use {
and }
in the Object Pascal/Delphi example.
Double-Slash-Whole-Block-Switching (Object Pascal/Delphi only)
The Object Pascal dialect used in Delphi supports three ways of commenting code, two for commenting whole blocks ( { }
and (* *)
) and one for commenting lines ( //
).
We can exploit this feature to switch between two code blocks easily and fast:
Block 2 is in the enabled state:
{ Block 1 (commented block) (*} Block 2 (active block) //*)
Note, I am just adding two slashes in front of the first comment block to activate it again – similar to Double-Slash-Whole-Block-Commenting trick above. This will also magically disable the second block due to the way the comment marks are arranged:
//{ Block 1 (active block) (*} Block 2 (commented block) //*)
These tricks are probably applicable to other programming languages as well. Please let me know.