Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Better New File NamesNew to Visual Studio Code? Get it now.
Better New File Names

Better New File Names

Coder for Life

|
4 installs
| (0) | Free
Sanitizes the default Save As filename for new untitled files and warns about suspicious names after save.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Better New File Names

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

  1. 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.
  2. 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.
  • betterNewFileNames.warnOnSuspiciousNames (default: true)
    • 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.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft