This VS Code extension improves default filenames when saving new untitled editors, and warns when a saved name looks suspicious. That helps intro CS students avoid names copied from the first line of code (with #, parentheses, and other symbols) that break terminals and automated runners.
What it does
Sanitized Save / Save As defaults — for untitled editors, Cmd/Ctrl+S and Cmd/Ctrl+Shift+S open the save dialog with a cleaned default name derived from the first useful line of content (special symbols removed), plus a language-appropriate extension. You can still type any name you want.
Suspicious name warning — after a file is saved, if the name starts with Untitled (any case) or contains special characters, a warning offers a one-click rename. Python files use stricter rules (valid identifier).
Python-specific rules
When choosing a default name, blank lines and import / from … import lines are skipped.
The suggested basename is turned into a valid identifier (spaces and hyphens become underscores; other symbols are removed).
After save, names that are not valid Python identifiers are treated as suspicious.
Settings
betterNewFileNames.enabled (default: true)
Use a sanitized default filename when saving untitled editors via the extension’s Save / Save As keybindings.
After save, warn when the file name looks suspicious and offer to rename.
Development
Install dependencies:
npm install
Compile:
npm run compile
Run extension for testing:
Press F5 in VS Code to start an Extension Development Host.
Package for distribution:
npx @vscode/vsce package --no-dependencies
Save behavior notes
VS Code does not expose an API to change the built-in Save dialog’s default name. This extension contributes Cmd/Ctrl+S and Cmd/Ctrl+Shift+S keybindings for untitled editors so the sanitized default is used for the common keyboard save path. Saving from the File menu still uses VS Code’s built-in dialog; the suspicious-name warning still applies after that save.