Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 462395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:04:13+00:00 2026-05-12T23:04:13+00:00

In vs2008, how can I (possibly with a macro) assign a shortcut key to

  • 0

In vs2008, how can I (possibly with a macro) assign a shortcut key to collapse to definitons but leave regions expanded (they must expand if collapsed)?

EDIT: I hate regions but my co-workers does not (: So I want this to avoid the regions used by them.

I read jeff’s post. Ctrl M + O is what I really want to do, if there were not regions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:04:13+00:00Added an answer on May 12, 2026 at 11:04 pm

    I believe I have finally got the answer that I’ve been looking for, and I think it might help you as well, @Serhat. You said:

    I read jeff’s post. Ctrl M + O is what I really want to do, if there were not regions.

    That was exactly what I was thinking to myself. I continued that line of thought and worked on a way to (temporarily) get rid of the #regions.

    This isn’t a complete solution, but I’m so glad to have something that I’m on the verge of jumping up and down. I will try to make these directions as easy as possible, although I daresay it may simply be easier to post the actual content of the macros I’ve created. (see link at bottom)

    I’ve created two macros:

    1. Comment out all #region and #endregion directives.
    2. Uncomment all //#region and //#endregion occurrences.

    Create the first macro:

    • Start recording a macro with Ctrl+Shift+R, and follow these steps:
    • Ctrl+H, Find what: #region, Replace with: //#region
    • Alt+A for Replace All
    • Ctrl+H, Find what: #endregion, Replace with: //#endregion
    • Alt+A for Replace All
    • End recording the macro with Ctrl+Shift+R
    • Open the Macro Explorer with Alt+F8 or Tools | Macros > Macro Explorer
    • Rename TemporaryMacro to CommentRegionDirectives

    Then, create the second macro:

    • Start recording a macro with Ctrl+Shift+R, and follow these steps:
    • Ctrl+H, Find what: //#region, Replace with: #region
    • Alt+A for Replace All
    • Ctrl+H, Find what: //#endregion, Replace with: #endregion
    • Alt+A for Replace All
    • End recording the macro with Ctrl+Shift+R
    • Open the Macro Explorer with Alt+F8 or Tools | Macros > Macro Explorer
    • Rename (this new) TemporaryMacro to UncommentRegionDirectives

    Now, save your macros in the Macro Explorer with Ctrl+S.

    Finally, assign shortcut keys to the two macros:

    • Open Tools | Options | Environment+Keyboard
    • In “Show commands containing:” type in Directives. This should show you your two macros, named “Macros.MyMacros.RecordingModule.CommentRegionDirectives” and “…UncommentRegionDirectives”
    • Highlight the CommentRegionDirectives entry and in the “Press shortcut keys:” box type Alt+/ then click the Assign button
    • Highlight the UncommentRegionDirectives entry and in the “Press shortcut keys:” box type Alt+Shift+/ then click the Assign button (by default these two shortcut combinations are not assigned to anything)
    • Click OK to save your shortcut assignments.

    Now, when you are faced with auto-collapsed #regions, hit Alt+/ to comment out the #region directives, and hit the standard Ctrl+M+O for Collapse to Definitions (if you so choose). Then later, before committing that unit with the commented-out #regions, just hit Alt+Shift+/ to uncomment the #regions and they will be reactivated.

    And finally, @Serhat, thank you again for your original comment which put me on this track in the first place.

    In practice there is one little hiccup that I am quite willing to live with. //#region followed by #//endregion counts as a contiguous comment and comments are still collapsed, but at least there is no code hidden in there.

    Here is the promised macro text I extracted from the Macro Explorer: http://pastebin.ca/1688618, although it shouldn’t be required if you manually follow the steps I outlined above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: VS2008 Setup Project: Shared (By All Users) Application Data Files? Please can
With which version(s) of VS2008/VSTS can I work with .dbproj files?
I'm looking for an add-in to VS2008 that can enable structural highlighting ( vertical
Is there any way I can get VS2008 to provide further detail on how
I came accross a very strange problem with tr1::regex (VS2008) that I can't figure
How can I tell if SP1 has been installed on VS2008? e.g. If I'm
How can I disable auto formatting for views (html files) in vs2008?
can I use .net framework 4.0 in VS2008 ? If yes how can I
I want to know how can I perform VS2008 load test from five different
Can I use EF4.0 relased with .NET framework 4.0 with VS2008?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.