How do I fold or collapse an arbitrary selection of code in Visual Studio Code? Is this feature supported?
Of course Sublime and Atom know this for ages.
How do I fold or collapse an arbitrary selection of code in Visual Studio Code? Is this feature supported?
Of course Sublime and Atom know this for ages.
Update for v1.70
In the Insiders Build v1.70 now is the functionality and command to truly hide arbitrary lines of code. The command is
Create Manual Folding Range from Selection
editor.createFoldingRangeFromSelection
It is bound to Ctrl+K Ctrl+, by default.
And
Remove Manual Folding Ranges
editor.removeManualFoldingRanges
It is bound to Ctrl+K Ctrl+. by default.
Still not supported. The proposed solutions here are not for the original question, which is to highlight any code and fold it--not to fold formal code blocks.
VS Code now allows arbitrary blocks of code to be marked with // #region and // #endregion to make them collapsible.
// #region Hello
console.log("Hello world")
// #endregion