by Andreas

Define a #Region in javascript files (Visual Studio 2010 / 2012)

In these times of super responsive client side processing mega javascript extravaganza web applications  you’re more than likely to end up with fairly large .js files in your projects. The standard code file in Visual Studio allows you to define collapsible sections by wrapping them with the #region / #endregion blocks. In javascript files however, you are restricted to collapsible functions only (“#region” is not recognized as anything valid):

image

Well, I just found out that that’s not entirely true. By marking a section of code (regardless of any logical blocks) and hitting CTRL + M + H you’ll define the selection as a region which is collapsible and expandable

image

  • http://sushantsblog.wordpress.com sushant kadam

    using ctrl + m+h you can make a section as collapsible and expandable.But how to undo the selection?????????????
    For eg:
    ctrl+k+c is for commenting code and
    ctrl+k+u for uncommenting code

    ctrl + m+h for collapsible and
    ?????? for undoin the action

    • Pungkas Yoga Kesuma

      ctrl+m+u

      • Mr Abiodun Adigun

        if ctr+m+u didn’t do the undo action then use ctr+u

    • Manoj Kumar

      Use Ctrl + M + P

  • http://blog.degree.no/bloggere/ Andreas

    CTRL M + P removes all regions in the document, give that a shot!

    http://msdn.microsoft.com/en-us/library/td6a5x4s.aspx

  • Anonymous

    tnx you are the champion

  • Tj Laubscher

    thnx really awesome to use cleans up my code nicely