Подтвердить что ты не робот

Visual Studio, Collapse/Расширяет только локальные области

Есть ли какой-либо ярлык, чтобы свернуть/расширить области ТОЛЬКО? Смысл, если у меня есть область с 5 методами в ней, и я удалю крах, регион рухнет, и когда я удалю развернуть, область будет расширяться, и я увижу все 5 методов с тем же состоянием, что и раньше ( разрушилась/расширенная).

В настоящее время ярлыки, которые я обнаружил, разрушают ВСЕ или расширяют ВСЕ, или заменяют слово "Все" для слова "Текущее".

Я ищу ярлык, который разрушит только регионы и не будет делать ничего с другими блоками внутри региона. То же самое с расширением.

Если такой вещи нет, может быть, кто-то нашел визуальное расширение для этого?

веселит Лукас

4b9b3361

Ответ 1

Вы можете использовать следующие макросы, чтобы развернуть/свернуть регионы, оставив состояние развернуть/свернуть отдельные методы как они были.

Я нашел макрос здесь. Обратите внимание, что мне пришлось прокомментировать вызов objSelection.EndOfDocument() из метода CollapseAllRegions, чтобы он работал правильно (используя Visual Studio 2010)

Imports EnvDTE
Imports System.Diagnostics
' Macros for improving keyboard support for "#region ... #endregion"
Public Module RegionTools
    ' 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 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 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 "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

Ответ 2

почему бы просто не нажать

ctrl + m + m

в то время как курсор в #region regionname

Ответ 3

Я написал бесплатное расширение Visual Studio "" Menees VS Tools ", в котором содержатся команды для" Свернуть все регионы "и" Развернуть все регионы "". Он доступен для версий VS с 2003 по 2013 год. VS 2013 и VS 2012 доступны в галерее Visual Studio.