‹ BackHN Continuity

Thread

Small programming tricks

681 points · 294 comments · signa11

  1. customguy · · focus · HN ↗
    I am so proud of this (I'm sure others came up with it way before me, but I still came up with it all by myself!)

        //*
            normal path
        /*/
            debug path
        //*/
    
    take away the the first slash to toggle the debug zone ON!
    1. spartanatreyu · · focus · HN ↗
      I always did it as:

      /**/

          Debug code to toggle on and off
      
      /**/

          Other debug code to toggle on and off
      
      /**/

      And toggled by removing the last slash on one of the comment lines.

      Having two `*` characters worked better for syntax highlighting at the time.

      Then I learned about Ctrl/Cmd + / to toggle a line or region on and off.

      But I still use the old technique when code editors can't handle where comments are supposed to start and stop and commenting out too much or breaking the indentation, typically breaking around modern CSS's newer features or languages embedded within other languages.

      1. mitxela · · focus · HN ↗
        /*/ is a comment "else", so you only need to change the first line to switch branches.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.