A powerful VS Code extension that automatically folds newly opened files according to preconfigured folding levels, helping you better organize and navigate your code.
- 🚀 Auto Folding: Automatically fold code according to configured levels when opening files
- ⚡️ Fast Response: Execute folding operations immediately after file opening
- 🎯 Precise Control: Support for configuring multiple folding levels
- 🔧 Flexible Configuration: Customizable folding delay time
- 💡 Smart Recognition: Support for all file types with code folding capabilities
- Open VS Code
- Press
Cmd+P(macOS) orCtrl+P(Windows/Linux) to open the command palette - Type
ext install auto-foldxand press Enter - Click the "Install" button to install the extension
- Reload VS Code to activate the extension
Alternatively, you can visit the VS Code Marketplace to install this extension directly.
The extension provides the following configuration options:
Defines the folding level configuration to apply when files are opened. Supports two configuration modes:
Mode 1: Simple Array Configuration (applies to all files)
- Type:
number[] - Default:
[2, 3] - Range:
1-7 - Examples:
[1]- Fold only the first level[1, 2]- Fold the first and second levels[1, 2, 3]- Fold the first three levels[]or[0]- Disable auto folding
Mode 2: Object Configuration (different folding levels for different file types)
{
"default": [2, 3],
"patterns": [
{
"pattern": ".vue",
"foldLevels": [2, 3, 4, 5]
},
{
"pattern": ".tsx",
"foldLevels": [2, 3, 4, 5]
},
{
"pattern": ".jsx",
"foldLevels": [2, 3, 4, 5]
},
{
"pattern": ".ts",
"foldLevels": [2, 3, 4]
},
{
"pattern": ".js",
"foldLevels": [2, 3, 4]
},
{
"pattern": ".py",
"foldLevels": [2, 3, 4]
},
{
"pattern": ".json",
"foldLevels": [2, 3, 4]
}
]
}- default: Default folding levels for files that don't match any specific patterns
- patterns: Array of file patterns, supports glob syntax or file extensions (like
.ts,.js,.vue)
Defines the delay time to wait before executing folding operations after files are opened.
- Type:
number - Default:
300 - Unit: milliseconds
- Range:
0-5000
- After installing and enabling the extension, it will automatically take effect
- Open any file that supports code folding
- The extension will automatically fold code blocks according to your configuration
- You can manually adjust the folding state at any time using VS Code's fold/unfold commands
- Clone the repository and install dependencies:
git clone https://github.com/yourusername/auto-fold.git
cd auto-fold
pnpm install- Open the project in VS Code
- Press
F5to start debugging mode
-
Compile:
pnpm run compile
-
Watch Mode:
pnpm run watch
-
Linting:
pnpm run lint
-
Type Checking:
pnpm run check-types
-
Run Tests:
pnpm run test
-
Package the extension:
pnpm run package
-
Publish the extension:
pnpm run publish
Note: Please ensure you have updated the version number and passed all tests before publishing.
- ✅ Support different folding configurations corresponding to different files
We welcome all forms of contributions, including but not limited to:
- 🐛 Bug reports
- 💡 Feature suggestions
- 📝 Documentation improvements
- 🔧 Code fixes
- ✨ New feature implementations
- Fork this repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Be friendly and professional
- Describe your changes in detail
- Follow the existing code style
- Add necessary tests
- Update relevant documentation
- 🎉 Initial release
- ✨ Implemented basic auto-folding functionality
- ⚙️ Added custom configuration options
- 📚 Completed basic documentation
- 🔧 Improved engine compatibility
- ✨ Added support for multiple folding levels
- 🔧 Fixed extension configuration tips
This project is licensed under the MIT License - see the LICENSE file for details
