Code Block Toggler

I came across one of the most awesome meta-language features for C-style languages (specifically any language that has /* */ and // comment support). The nitty-gritties are up at a rather good blog. I whipped up a snippet to handle this automatically.

It has a few notable features – it gives a reason for the flip, it wraps it in a region, it has a auto-task FLIP: prefix and it explains how it’s used.

            #region Flip - This new behaviour is experimental. -
            // FLIP: This new behaviour is experimental.
            //*/// Two proceding slashes will activate the first block, one will activate the second.
            Console.ReadLine();
            /*/
            Console.ReadLine();
            //*/
            #endregion Flip - This new behaviour is experimental. -

Drop it in your My Code Snippets folder. In VS select the code you want to flip-comment, Hold CTRL, Press K, Press S, Release CTRL, Press M, Press Enter, Press F, Press Enter (I wish you could assign hot keys to snippets!).

Code Block Flipper (WordPress won’t let me upload .snippet – so you will need to rename it)

This entry was posted in Programming, Top Hacks, Tricks. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>