Auto Fold is a Visual Studio Code extension that automatically folds and unfolds code sections, particularly import statements, based on user interactions and configurations. It supports JavaScript, TypeScript, and other languages.
- Automatically folds import statements when a document is opened.
- Unfolds or folds import sections based on text editor selection changes.
- Provides two methods for folding imports:
- String Search Imports: Manually searches for import statements in JavaScript/TypeScript files.
- Folding Range Imports: Uses VS Code's folding range provider for more accurate folding.
The extension provides the following configuration options:
- Type:
boolean - Default:
true - Description: Enable auto fold/unfold on open. This is not the default behavior of VSCode. But the default behavior of vscode sometime does not work. So this is enabled by default.
- Type:
boolean - Default:
true - Description: When the import section is focused, it unfolds all imports. When the import section is blurred, it folds all imports.
- Type:
boolean - Default:
true - Description: Enables string search for imports in JavaScript files. This is useful when VS Code's default folding behavior does not work as expected.
- Type:
integer - Default:
1 - Description: The number of lines to add as padding when focusing or blurring the import section. This helps in ensuring that the import section is fully visible when unfolded.
- Install the extension from the VS Code marketplace or clone this repository and build it locally.
- Open a JavaScript or TypeScript file with import statements.
- The extension will automatically fold the import statements based on the configuration.
- Modify the settings in your VS Code
settings.jsonfile to customize the behavior:
{
"auto-fold.fold/unfold-imports-when-focus/blur": true,
"auto-fold.enable-str-search-imports-for-js": true
}This project is licensed under the MIT License. See the LICENSE file for details.