大綱Outlining

您可以選擇隱藏一些程式碼,方法是折迭程式碼區域,使其出現在加號 (+) 。You can choose to hide some code from view by collapsing a region of code so that it appears under a plus sign (+). 您可以按一下加號來展開已摺疊的區域You expand a collapsed region by clicking the plus sign. 如果您是鍵盤使用者,您可以選擇Ctrl + M + m以折迭和展開。If you are a keyboard user, you can choose Ctrl+M+M to collapse and expand. 您也可以摺疊大綱區域,方法是按兩下大綱邊界之區域中的任一行,而大綱邊界出現在程式碼左邊。You can also collapse an outlining region by double-clicking any line in the region on the outlining margin, which appears just to the left of the code. 當您將滑鼠停留在已摺疊的區域上方時,已摺疊區域的內容會成為工具提示。You can see the contents of a collapsed region as a tooltip when you hover over the collapsed region.

注意

本主題適用於 Windows 上的 Visual Studio。This topic applies to Visual Studio on Windows. 針對 Visual Studio for Mac,請參閱原始檔編輯器 (Visual Studio for Mac )For Visual Studio for Mac, see Source editor (Visual Studio for Mac).

當您將滑鼠停留在邊界上方時,也會反白顯示大綱邊界中的區域。Regions in the outlining margin are also highlighted when you hover over the margin with the mouse. 在某些色彩組態中,預設反白顯示色彩似乎太過模糊。The default highlighting color may seem rather faint in some color configurations. 您可以在 [工具 > 選項] > 環境字型 > > ** **[可折迭區域] 中變更它。You can change it in Tools > Options > Environment > Fonts and Colors > Collapsible Region.

當您使用大綱程式碼時,可以展開您想要處理的區段,並在完成時予以摺疊,然後移至其他區段。When you work in outlined code, you can expand the sections you want to work on, collapse them when you are done, and then move to other sections. 當您不想要顯示大綱時,可以使用 [取消大綱]**** 命令以移除大綱資訊,而不干擾基礎程式碼。When you do not wish to have outlining displayed, you can use the Stop Outlining command to remove the outline information without disturbing your underlying code.

[編輯]**** 功能表上的 [復原]**** 和 [重做]**** 命令會影響這些動作。The Undo and Redo commands on the Edit menu affect these actions. [複製]****、[剪下]****、[貼上]**** 和拖放作業都會保留大綱資訊,而不是可摺疊區域的狀態。The Copy, Cut, Paste, and drag-and-drop operations retain outlining information, but not the state of the collapsible region. 例如,當您複製已摺疊的區域時,[貼上]**** 作業會將複製的文字貼為已展開的區域。For example, when you copy a region that is collapsed, the Paste operation will paste the copied text as an expanded region.

警告

當您變更大綱區域時,可能會遺失大綱。When you change an outlined region, the outlining may be lost. 例如,刪除或 尋找和取代 作業可能會清除區域結尾。For example, deletions or Find and Replace operations may erase the end of the region.

您可以在 [編輯 > 大綱] 子功能表中找到下列命令。The following commands can be found on the Edit > Outlining submenu.

NameName 描述Description
隱藏選取範圍Hide Selection (ctrl + Mctrl + H) -折迭選取的程式碼區塊,通常不能用於大綱,例如 if 區塊。(Ctrl+M, Ctrl+H) - Collapses a selected block of code that would not normally be available for outlining, for example an if block. 若要移除自訂區域,請使用 [取消隱藏目前大綱]**** (或 Ctrl+MCtrl+U)。To remove the custom region, use Stop Hiding Current (or Ctrl+M, Ctrl+U). 在 Visual Basic 中無法使用。Not available in Visual Basic.
切換大綱展開Toggle Outlining Expansion (ctrl + mctrl + m) -當游標位於嵌套折迭的區段時,將最內層大綱區段的目前隱藏或展開狀態反轉。(Ctrl+M, Ctrl+M) - Reverses the current hidden or expanded state of the innermost outlining section when the cursor lies in a nested collapsed section.
切換所有大綱Toggle All Outlining (ctrl + Mctrl + L) -將所有區域設定為相同的折迭或展開狀態。(Ctrl+M, Ctrl+L) - Sets all regions to the same collapsed or expanded state. 如果有些區域展開,有些區域摺疊,則會展開摺疊區域。If some regions are expanded and some collapsed, then the collapsed regions are expanded.
取消大綱Stop Outlining (ctrl + Mctrl + P) -移除整份檔的所有大綱資訊。(Ctrl+M, Ctrl+P) - Removes all outlining information for the entire document.
取消隱藏目前的Stop Hiding Current (ctrl + Mctrl + U) -移除目前所選取使用者定義區域的大綱資訊。(Ctrl+M, Ctrl+U) - Removes the outlining information for the currently selected user-defined region. 在 Visual Basic 中無法使用。Not available in Visual Basic.
摺疊至定義Collapse to Definitions (ctrl + Mctrl + O) -折迭所有類型的成員。(Ctrl+M, Ctrl+O) - Collapses the members of all types.
折迭區塊:<logical boundary>Collapse Block:<logical boundary> (c + +) 折迭包含插入點的函式區域。(C++) Collapses a region in the function containing the insertion point. 例如,如果插入點落在迴圈內,則會隱藏迴圈。For example, if the insertion point lies inside a loop, the loop is hidden.
全部折迭: <logical structures>Collapse All in: <logical structures> (c + +) 折迭函數內部的所有結構。(C++) Collapses all the structures inside the function.

您也可以使用 Visual Studio SDK 來定義您想要展開或摺疊的文字區域。You can also use the Visual Studio SDK to define the text regions you want to expand or collapse. 請參閱逐步解說︰大綱See Walkthrough: Outlining.

另請參閱See also