Collapse all #regions only(!) in C# (Visual Studio)

前端 未结 10 1669
予麋鹿
予麋鹿 2020-12-12 15:11

There\'s a number of keyboard shortcuts and menu commands to automatically expand or collapse all foldables in the current document. Ctrl+M, Ctrl

相关标签:
10条回答
  • 2020-12-12 15:49

    Ctrl+M+O will collapse all.

    Ctrl+M+L will expand all. (in VS 2013 - Toggle All outlining)

    Ctrl+M+P will expand all and disable outlining.

    Ctrl+M+M will collapse/expand the current section.

    These options are also in the context menu under Outlining.

    Right click in editor -> Outlining to find all options. (After disabling outlining, use same steps to enable outlinging.)

    0 讨论(0)
  • 2020-12-12 15:49

    To collapse regions : Tools > Options > Text Editors > C# > Advanced > Check "Collapse #regions when collapsing to definitions"

    0 讨论(0)
  • 2020-12-12 15:49

    I recommend using the free Visual Studio extension "Menees VS Tools Extension for Visual Studio." Just search for it in Tools --> Extensions and Updates in Visual Studio. Once installed you just have to hit Ctrl+M+K and just the regions will be collapsed. Here is their website https://marketplace.visualstudio.com/items?itemName=BillMenees.MeneesVSTools2013

    To edit the settings look under Tools --> Options --> Menees VS Tools --> General.

    0 讨论(0)
  • 2020-12-12 15:56

    Select All via Ctrl A and then Ctrl M M

    i.e. Press M twice while holding down Ctrl

    0 讨论(0)
  • 2020-12-12 16:04

    I know this is an old question, but here's an update for visual studio 2019:

    The Quick Tasks solution from @ygoe's answer does not work for Visual Studio 2019, because that version changed the way the Quick Task bar searches. Plus it was never the preferred solution to the original question, since you needed to type a quick action instead of having a keyboard shortcut.

    I found a different solution on the marketplace which does exactly the collapsing and expanding of all regions in the currently opened file with keyboard shortcuts: Collapse Region

    From the extension page:

    Default key bindings are (Ctrl+R, Ctrl+Num+) and (Ctrl+R, Ctrl+Num-). Can be changed in Tools->Options->Environment->Keyboard.

    0 讨论(0)
  • 2020-12-12 16:04

    tick the Checkmark in Settings -> TextEditor -> C# -> Advanced -> Collapse #regions when collapsing definitions.

    then right click in the editor > outlining > collapse to defenitions

    0 讨论(0)
提交回复
热议问题