File Filler — Auto-insert templates into new files
File Filler automatically inserts starter content/templates into newly created files in VS Code, helping maintain consistency and speed up project setup. It supports both files created via the VS Code Explorer and those created externally (e.g., CLI, generators).
Features
Auto-detects new files and inserts predefined templates based on file extension.
Supports UI-created files and external file creation via a file watcher.
Built-in templates for common file types (JS, PY, HTML) and customizable templates via settings.
Non-destructive: skips files that already contain content.
Live settings: toggling settings updates behavior without requiring reload.
How it works
Listens for:
File creations through VS Code: workspace.onDidCreateFiles
File system creations: FileSystemWatcher (glob configurable through settings)
On creation, if the file is empty, File Filler injects the appropriate template.
Requirements
Visual Studio Code (latest stable recommended)
No additional dependencies required
Extension Settings
This extension contributes the following settings (open Settings and search “File Filler” or edit settings.json):
Glob pattern for the file watcher (used to detect externally created files).
Usage
Install the extension and open a workspace.
Create a new file (e.g., index.js, app.py, page.html).
If the file is empty, File Filler inserts a matching template automatically.
Customize templates via Settings to fit team/project standards.
Built-in Templates
JavaScript (.js)
Strict mode, main function, runnable boilerplate.
Python (.py)
Shebang, docstring, main guard.
HTML (.html)
Minimal HTML5 document structure.
Tip: Add more formats through autoFileContent.customTemplates to match frameworks or project conventions.
Commands
File Filler: Hello World (file-filler.helloWorld)
Demo command for verifying that the extension is active.
Known Limitations
If a file is not empty at the time of detection, the template is not applied.
Some file systems or network drives may delay or coalesce file events.
External file creation detection depends on the watcher glob pattern and OS notifications; adjust autoFileContent.watchPattern as needed for large monorepos.
Troubleshooting
The template didn’t apply:
Ensure the file was empty upon first open.
Verify autoFileContent.enabled is true.
Confirm the extension or custom template exists for the file’s extension.
Adjust autoFileContent.watchPattern to include the file path.
No events are detected:
Check that VS Code ran with a workspace/folder open.
Ensure the extension is activated on startup (activation events set by the extension).
Security and Performance
No external network calls or data collection.
Uses efficient event listeners and disposes resources on deactivation.
The watcher pattern is configurable; prefer narrower globs in very large workspaces.
Release Notes
1.0.0
Initial release:
Auto-template on new file creation (VS Code and file system).