Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Fold/Unfold Selection OnlyNew to Visual Studio Code? Get it now.
Fold/Unfold Selection Only

Fold/Unfold Selection Only

Sammy

|
2 installs
| (0) | Free
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Fold / Unfold Selection Only

Visual Studio Marketplace Installs

A VS Code extension that adds Fold / Unfold commands which only act inside the current selection.
Perfect when you want to collapse or expand code just in the region you care about, without affecting the rest of the file.

Icon


✨ Features

  • Fold Everything Inside Selection
    Collapse all foldable regions that are fully contained in your current selection.

  • Unfold Everything Inside Selection
    Expand all foldable regions fully contained in your current selection.

  • Toggle Fold/Unfold Inside Selection
    If anything inside the selection was previously folded, it unfolds; otherwise it folds.

  • Works in any language that provides folding ranges (JavaScript, TypeScript, JSON, XML, Python, etc.).

  • Integrates with Right Click Code Folding:

    • If installed, your commands appear in its Fold / Unfold submenu.
    • If not, the extension automatically provides its own submenu.

⌨️ Commands & Keybindings

Command Default Keybinding
Fold Everything Inside Selection Ctrl+K ,
Unfold Everything Inside Selection Ctrl+K .
Toggle Fold/Unfold Inside Selection Ctrl+K ;

Keybindings only work when the editor has focus and you have an active selection.


📂 Context Menu

  • Right-click inside the editor → Fold / Unfold submenu.
  • Your three commands appear alongside the standard folding actions.
  • If Right Click Code Folding extension is installed, your commands merge into its submenu.
  • If not, this extension provides its own submenu.

🚀 Installation

  1. Install from the Visual Studio Marketplace
    or search Fold/Unfold Selection Only in VS Code’s Extensions view.
  2. Reload VS Code.

⚙️ Configuration

No configuration required.
Optional: customize or rebind the keybindings in your Keyboard Shortcuts (Ctrl+K Ctrl+S).


🛠 Development

Clone and build locally:

git clone https://github.com/hoffsam/fold-selection-only.git
cd fold-selection-only
npm install
npm run compile
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft