如何在Visual Studio代码中折叠或折叠代码节?
支持该特性吗?
如何在Visual Studio代码中折叠或折叠代码节?
支持该特性吗?
当前回答
在Mac上,它是RHS命令键,⌘K,而不是用于代码折叠命令的左侧。
否则,左手命令键将删除当前行,⌘K。
其他回答
命令K +命令0无效。
我希望Visual Studio Code可以处理:
#region Function Write-Log
Function Write-Log {
...
}
#endregion Function Write-Log
现在Visual Studio Code只是忽略它,不会折叠它。 与此同时,notepad++和PowerGUI可以很好地处理这个问题。
更新:我刚刚注意到Visual Studio Code的更新。现在支持了!
从版本1.3.1(2016-07-17)开始,块崩溃变得更加方便。
任何后跟缩进的行都将有一个'-'字符以允许折叠。如果该块被折叠,那么它将被一个'+'字符所取代,该字符将打开折叠的块。
(Ctrl + Shift + Alt +])仍然会影响所有方块,关闭一层。每重复使用一次,就会关闭一层。Ctrl + Shift + Alt +[)的作用正好相反。
万岁,区块崩溃终于有用了。
注意:这些快捷方式只有在编辑keybindings.json时才能正常工作
我不喜欢默认的快捷方式,我想让他们工作如下:
折叠:Ctrl + Alt +] 使用Ctrl + Shift + Alt + 全部折叠:Ctrl + k然后Ctrl +] 展开:Ctrl + Alt + [ 用Ctrl + Shift + Alt + [ 全部展开:Ctrl + k然后Ctrl + [
设置方法:
打开快捷键(JSON) (Ctrl + Shift + p) 将以下代码片段添加到该文件中 已经为折叠/展开自定义键绑定?然后你需要更换它们。
{
"key": "ctrl+alt+]",
"command": "editor.fold",
"when": "editorTextFocus && foldingEnabled"
},
{
"key": "ctrl+alt+[",
"command": "editor.unfold",
"when": "editorTextFocus && foldingEnabled"
},
{
"key": "ctrl+shift+alt+]",
"command": "editor.foldRecursively",
"when": "editorTextFocus && foldingEnabled"
},
{
"key": "ctrl+shift+alt+[",
"command": "editor.unfoldRecursively",
"when": "editorTextFocus && foldingEnabled"
},
{
"key": "ctrl+k ctrl+[",
"command": "editor.unfoldAll",
"when": "editorTextFocus && foldingEnabled"
},
{
"key": "ctrl+k ctrl+]",
"command": "editor.foldAll",
"when": "editorTextFocus && foldingEnabled"
},
如果任何快捷键都不起作用(就像对我来说),作为一种变通方法,你也可以打开命令面板(Ctrl + 3或View ->命令面板…)并键入折叠全部: