如何折叠visualstudiocodeforwindows中的代码部分?

2024-04-26 12:11:19 发布

您现在位置:Python中文网/ 问答频道 /正文


Tags: python
3条回答

v1.39增加了使用命令editor.toggleFold切换折叠功能。

默认情况下,它绑定到Ctrl+KCtrl+L。见https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_39.md#toggle-folding


区域进行的代码折叠已随v1.17一起提供。Folding by regions documentation。以及v1.191.23

TypeScript/JavaScript: //#region and //#endregion and //region and //endregion
C#:                    #region and #endregion
C/C++:                 #pragma region and #pragma endregion
F#:                    //#region and //#endregion
PowerShell:            #region and #endregion
Python:                #region and #endregion
VB:                    #Region and #End Region
PHP:                   #region and #endregion
Bat:                   ::#region and ::#endregion

Each language also has snippets available for the markers. Type '#' and invoke code completion to see them. To have region markers configured for your language, contact the language extension provider.

v1.23增加了CSS/SCSS/更少的代码折叠区域:

CSS/SCSS/Less:         /* #region */ and /* #endregion */ or /*#region*/ and /*#endregion*/
SCSS/Less:             // #region and // #endregion

增加1.35版:

Go:                   // region, // endregion and // #region, // #endregion

v.1.36添加了shellscript,请参阅[github问题:添加shellscript折叠标记]。4

shellscript:          # region and # endregion

自2017年4月Visual Studio代码版本1.12.0起,请参见文档中的Basic Editing > Folding部分。

默认键为:

Fold All: CTRL+K, CTRL+0 (zero)

Fold Level [n]: CTRL+K, CTRL+[n]*

Unfold All: CTRL+K, CTRL+J

Fold Region: CTRL+K, CTRL+[

Unfold Region: CTRL+K, CTRL+]

*折叠级别:要折叠除最外层类之外的所有类,请尝试CTRL+KCTRL+1

Macs:使用而不是CTRL(谢谢Prajeet)

Folding已经推出,现在从Visual Studio代码version 0.10.11开始实现。有以下键盘快捷键可用:

  • 折叠折叠光标最里面的未折叠区域:

    • 在Windows和Linux上,Ctrl+Shift+[
    • macOS上的.+.+[
  • 展开展开光标处的折叠区域:

    • 在Windows和Linux上,Ctrl+Shift+]
    • 在macOS上
  • 全部折叠在编辑器中折叠所有区域:

    • Ctrl+(K=>;0)(零)在Windows和Linux上
    • +(K=>;0)(零)在macOS上
  • 全部展开在编辑器中展开所有区域:

    • Ctrl+(K=>;J)在Windows和Linux上
    • +(K=>;J)在macOS上

引用:https://code.visualstudio.com/docs/getstarted/keybindings

相关问题 更多 >