Is it possible to close all closable code segments of some kind in VS Code?
For example I want all my style property code segments to be closed by default and only open them when they are hovered. Is this possible? They get extremely huge and make a component unreadable.
Not that I know of (without using extensions). But you can get pretty close.
You can fold (collapse) all folding regions in an editor by using the Fold All
command in the command palette, or whatever keyboard shortcut that command is bound to by default. On Windows and Linux, it's bound to ctrl+k,cltr+o. I assume that on macOS, you just switch ctrl in the previous shortcut with cmd. VS Code remembers things about the workspace state like which folding regions are folded or not folded. It will recall that info when reopening a closed editor tab, or reopening the workspace.
If you're opening to trying extensions, try @rioV8's rioj7.commandOnAllFiles
(I have no affiliation with this extension) (see also How to execute command across multiple files in VS Code?), where usage might look something like this:
settings.json:
"commandOnAllFiles.commands": {
"Fold All Folding Regions": {
"command": "editor.foldAll"
}
}
keybindings.json:
{
"key": "ctrl+i o", // or any other key combo
"command": "commandOnAllFiles.applyOnWorkspace",
"args": ["Fold All Folding Regions"]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With