A VSCode/Windsurf extension that collapses all outermost code blocks (functions, arrays, objects) while keeping their inner content expanded. This helps you get a quick overview of your code structure while maintaining access to the implementation details.
- Collapses outermost code blocks (defined by {}, [], or () pairs)
- Preserves inner content expansion
- Handles nested blocks correctly
- Skips blocks within string literals
- Works with any file type
- Configurable ignore patterns to skip specific lines
You can configure which lines to ignore using regular expressions in your VSCode settings:
{
"outerBlockCollapse.ignorePatterns": [
"^@", // Ignore lines starting with @
"^\\s*import ", // Ignore import statements
"^\\s*from " // Ignore from statements
]
}
By default, the extension ignores lines starting with @
(common for decorators). You can add more patterns in your settings.json or through the Settings UI.
- Download the latest
.vsix
file from the releases - Open VSCode
- Press
Ctrl+Shift+X
(Windows/Linux) orCmd+Shift+X
(Mac) to open the Extensions view - Click on the "..." (More Actions) menu
- Select "Install from VSIX..."
- Choose the downloaded .vsix file
- Download the latest
.vsix
file from the releases - Open Windsurf
- Press
Ctrl+Shift+X
(Windows/Linux) orCmd+Shift+X
(Mac) to open the Extensions view - Click on the "..." (More Actions) menu
- Select "Install from VSIX..."
- Choose the downloaded .vsix file
You can collapse outer blocks in two ways:
- Windows/Linux: Press
Ctrl+K Ctrl+0
- Mac: Press
Cmd+K Cmd+0
- Open any code file
- Open the command palette (
Ctrl+Shift+P
/Cmd+Shift+P
) - Type "Collapse Outer Blocks" and select the command
- The outermost blocks will be collapsed while inner content remains expanded
The keyboard shortcut was chosen to be similar to VSCode's built-in "Fold All" (Ctrl+K Ctrl+0
), making it intuitive for users familiar with VSCode's folding shortcuts.
- Node.js (v14 or higher)
- npm or yarn
- VSCode (for testing)
- Clone the repository:
git clone <your-repo-url>
cd outer-block-collapse
- Install dependencies:
yarn install
- Build the extension:
yarn run compile
- Press F5 in VSCode to launch a new Extension Development Host window
- Open a file with some nested blocks
- Use the command palette to run "Collapse Outer Blocks"
- Make changes to the code and press F5 to reload
- Install vsce globally:
npm install -g @vscode/vsce
- Package the extension:
vsce package
This will create a .vsix
file in your directory that can be installed in VSCode or Windsurf.
outer-block-collapse/
├── package.json # Extension manifest
├── tsconfig.json # TypeScript configuration
├── README.md # This file
└── src/
└── extension.ts # Extension source code
MIT
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests (if available)
- Submit a pull request
- The extension currently doesn't handle language-specific block markers (like Python's indentation)
- Block detection is based on character matching and might not handle all edge cases in comments or strings