Share via


Keyboard Shortcut For Expand/Collapse

Question

Tuesday, February 12, 2019 8:10 PM

Does anybody know the keyboard shortcut to expand/collapse a region of code? Similar to clicking the small plus sign on the left side of the code. After Googling it, I see many answers that state CTRL+M, CTRL+M, but when I use CTRL+M once it <g class="gr_ gr_250 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="250" id="250">delete</g> the line where the cursor is located? I could also assign a custom shortcut, but I do not know the name of the command to expand/collapse.

Thanks.

All replies (4)

Tuesday, February 12, 2019 9:07 PM

>Does anybody know the keyboard shortcut to expand/collapse a region of code? Similar to clicking the small plus sign on the left side of the code. After Googling it, I see many answers that state CTRL+M, CTRL+M

Ctrl+M,Ctrl+M is the default. If you want to see what accelerator you have, look at the menu item: Edit, Outlining, Toggle Outlining
Expansion.

If you want to change it, use: Tools, Options, Environment, Keyboard, and enter ToggleOutliningExpansion into the "Show commands
containing" field.

Dave


Wednesday, February 13, 2019 7:49 AM

Hi friend,

Welcome to MSDN forum.

The default shortcut keys in vs are (collapse) is CTRL + M +CTRL + S and (expand) CTRL + M+CTRL + E, you also can use CTRL+ M +CTRL + M to collapse/expand it, please check this: Default keyboard shortcuts. They are key combination, once you press Ctrl+M and you can check the status as below, waiting for second key to trigger this function. If your behavior is not the same, please go to Tools-Import and Export setting…-Reset all settings to reset setting to the default one, then check it again.

If you want to custom the shortcut, please go to tools>> options>>settings>>environment>>keyboard, the name of commands are Edit.CollapseCurrentRegion and Edit.ExpandCurrentRegion and set you own shortcuts.

Best regards,

Sara

MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]


Tuesday, February 19, 2019 5:59 AM

Hi friend,

Do you have any updates? If our solutions not solve your issue, please feel free to let us know.

BTW, if you think our replies are helpful for your issue, please mark it as answer, it benefits for other community members to easier this useful information, thanks in advance.

Have a nice day!

Best regards,

Sara

MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]


Wednesday, June 26, 2019 2:17 PM

Hi Sara,

I just noticed that I do not have email notifications turned on for this account and I forgot that I made this topic. The suggestion that you posted did not work. CTRL+M always deletes a line for me. I searched the the keyboard shortcuts and saw that CTRL+M was assigned to CutLine. I changed the mapping for CutLine, but CTRL+M was still deleting the line. 

I then assigned CollapseCurrentRegion to CTRL+K, CTRL+\ When I tested this shortcut on some code. The shortcut does nothing, so I am not sure what I am doing wrong.

Thanks.