Visual Studio展开/折叠键盘快捷键

ser*_*0ne 185 keyboard-shortcuts visual-studio visual-studio-2012

在Visual Studio中,如果我打开了代码文件,我可以按CTRL+ MCTRL+ M+ O折叠所有代码块,区域,命名空间等.

如何做相反的事情并扩展一切?

我用Google搜索了这个,但似乎找不到有效的捷径!

ser*_*0ne 323

折叠到定义

CTRL+ M,O

展开所有概述

CTRL+ M,X

展开或折叠所有内容

CTRL+ M,L

这也适用于TypeScript和JavaScript等其他语言

  • 我用Google搜索并得到你的答案;) (31认同)
  • 不要一次按下所有三个按钮!按住CTRL然后按M,然后按O或X. ;-) (7认同)

Sir*_*lih 125

如您所见,有几种方法可以实现这一目标.

我个人使用:

展开全部:CTRL+ M+L

全部折叠:CTRL+ M+O

奖金:

在光标位置展开/折叠:CTRL+ M+M

  • +1的奖金,我一直在寻找这个,但我总觉得它应该是不需要两次按键的东西......哦,在我的虚拟法拉利中的所有热键,我可以忍受这个. (12认同)
  • Ctrl MM是一个救生员.正是我在寻找的东西 (8认同)
  • 不想在那里重复其他评论,但Ctrl MM很棒,并且会节省我这么多时间! (6认同)
  • CMM +1互联网cookie为您服务.不是我想要的......更好!比我想要的. (2认同)
  • @Allstar 只需再次按 CTRL+M+M :-) (2认同)

W0l*_*0ds 26

Visual Studio 2015:

Tools > Options > Settings > Environment > Keyboard
Run Code Online (Sandbox Code Playgroud)

默认值:

Edit.CollapsetoDefinitions:CTRL + M+O

Edit.CollapseCurrentRegion:CTRL + M+CTRL + S

Edit.ExpandAllOutlining:CTRL + M+CTRL + X

Edit.ExpandCurrentRegion:CTRL + M+CTRL + E

我喜欢设置和使用IntelliJ的快捷方式:

Edit.CollapsetoDefinitions: CTRL + SHIFT + NUM-

Edit.CollapseCurrentRegion: CTRL + NUM-

Edit.ExpandAllOutlining: CTRL + SHIFT + NUM+

Edit.ExpandCurrentRegion: CTRL + NUM+


Ufu*_*arı 22

你可以使用Ctrl+ MCtrl+P

它叫做Edit.StopOutlining

  • @congusbongus如果先按Ctrl + M,则不会打印. (3认同)

小智 10

对于崩溃,您可以尝试CTRL+ M+ O并使用CTRL+ M+进行扩展P.这适用于VS2008.


Son*_*nja 8

转到工具 - >选项 - >文本编辑器 - > c# - >高级,取消选中第一个复选框打开文件时输入大纲模式.

这将永远解决这个问题


小智 5

我一直希望 Visual Studio 包含一个选项来折叠/展开区域。我有以下宏可以做到这一点。

Imports EnvDTE
Imports System.Diagnostics
' Macros for improving keyboard support for "#region ... #endregion"
Public Module CollapseExpandRegions
' Expands all regions in the current document
  Sub ExpandAllRegions()

    Dim objSelection As TextSelection ' Our selection object

    DTE.SuppressUI = True ' Disable UI while we do this
    objSelection = DTE.ActiveDocument.Selection() ' Hook up to the ActiveDocument's selection
    objSelection.StartOfDocument() ' Shoot to the start of the document

    ' Loop through the document finding all instances of #region. This action has the side benefit
    ' of actually zooming us to the text in question when it is found and ALSO expanding it since it
    ' is an outline.
    Do While objSelection.FindText("#region", vsFindOptions.vsFindOptionsMatchInHiddenText)
        ' This next command would be what we would normally do *IF* the find operation didn't do it for us.
        'DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
    Loop
    objSelection.StartOfDocument() ' Shoot us back to the start of the document
    DTE.SuppressUI = False ' Reenable the UI

    objSelection = Nothing ' Release our object

  End Sub

  ' Collapses all regions in the current document
  Sub CollapseAllRegions()
    Dim objSelection As TextSelection ' Our selection object

    ExpandAllRegions() ' Force the expansion of all regions

    DTE.SuppressUI = True ' Disable UI while we do this
    objSelection = DTE.ActiveDocument.Selection() ' Hook up to the ActiveDocument's selection
    objSelection.EndOfDocument() ' Shoot to the end of the document

    ' Find the first occurence of #region from the end of the document to the start of the document. Note:
    ' Note: Once a #region is "collapsed" .FindText only sees it's "textual descriptor" unless
    ' vsFindOptions.vsFindOptionsMatchInHiddenText is specified. So when a #region "My Class" is collapsed,
    ' .FindText would subsequently see the text 'My Class' instead of '#region "My Class"' for the subsequent
    ' passes and skip any regions already collapsed.
    Do While (objSelection.FindText("#region", vsFindOptions.vsFindOptionsBackwards))
        DTE.ExecuteCommand("Edit.ToggleOutliningExpansion") ' Collapse this #region
        'objSelection.EndOfDocument() ' Shoot back to the end of the document for
        ' another pass.
    Loop
    objSelection.StartOfDocument() ' All done, head back to the start of the doc
    DTE.SuppressUI = False ' Reenable the UI

    objSelection = Nothing ' Release our object

  End Sub
End Module
Run Code Online (Sandbox Code Playgroud)

编辑:现在有一个名为 Edit.ToggleOutliningExpansion (Ctrl+M, Ctrl+M) 的快捷方式可以做到这一点。