ScreenshotNeo

BlogHow-to

How to Save a File in Visual Studio Code

Save files in VS Code with keyboard shortcuts, Save As, Save All, Auto Save, recovery settings, and fixes for common save errors.

By the ScreenshotNeo team1 October 20265 min read

To save a file in Visual Studio Code, choose File > Save or press Ctrl+S on Windows/Linux, or Cmd+S on macOS. The dot on the editor tab disappears when the current changes are written to disk. VS Code requires an explicit save by default. See the official save and Auto Save documentation.

Save the file you are editing

  1. Open an existing file or create a new one in VS Code.
  2. Edit the file.
  3. Use one of these commands:
    • Windows/Linux: Ctrl+S
    • macOS: Cmd+S
    • Menu: File > Save
  4. Check the editor tab. A dot means there are unsaved changes; when the dot disappears, the file has been saved.

The Explorer may also display a badge for files with unsaved changes. Saving writes the editor’s current contents to the file path on disk; it does not create a backup or commit the change to Git.

Save a new file

If you opened an untitled editor, VS Code asks where to store it the first time you save.

  1. Press Ctrl+S (Windows/Linux) or Cmd+S (macOS), or choose File > Save.
  2. Select a folder.
  3. Enter a filename, including its extension when appropriate, such as app.js, main.py, or README.md.
  4. Choose Save.

After the first save, the normal Save command writes to that same path.

Save As: choose another name or location

Use Save As when you want a copy under a different filename, move the file to another folder, or change its extension.

Platform Shortcut Menu
Windows/Linux Ctrl+Shift+S File > Save As
macOS Shift+Cmd+S File > Save As

Save As selects a new destination. The original file remains unchanged unless you later edit and save it.

Save every modified file

Save All writes all modified open editors in one operation.

  • Windows: Ctrl+K, then S
  • macOS: Option+Cmd+S
  • Command Palette: open it with Ctrl+Shift+P (Windows/Linux) or Shift+Cmd+P (macOS), then run File: Save All

The command affects all dirty editors that VS Code can write. It does not save files that are only changed on disk by another program.

Turn on Auto Save

The quickest toggle is File > Auto Save. For precise behavior, open Settings and search for files.autoSave. Supported values are:

Value When VS Code saves Useful for
off Only after an explicit save command Maximum control
afterDelay After the configured delay Frequent incremental edits
onFocusChange When the editor loses focus Saving when switching files or panels
onWindowChange When the VS Code window loses focus Saving when switching applications

For delayed saving, configure files.autoSaveDelay. The documented default delay is 1000 milliseconds.

Settings JSON examples

{
  "files.autoSave": "afterDelay",
  "files.autoSaveDelay": 1000
}

Settings can apply at user, workspace, or language-specific scope. For example, you can enable delayed Auto Save generally and disable it for one language:

{
  "files.autoSave": "afterDelay",
  "[python]": {
    "files.autoSave": "off"
  }
}

Use the Settings editor when you want VS Code to validate values, or edit settings.json directly for repeatable configuration.

Manual Save versus Auto Save

Choice Trigger Trade-off
Manual Save Explicit shortcut or menu command You decide exactly when the file is written
Auto Save after delay Timer after edits Convenient, but partial edits can be written while you work
Auto Save on focus change Editor loses focus Good for file switching; timing depends on your workflow
Auto Save on window change VS Code window loses focus Useful when switching applications

What happens if VS Code closes unexpectedly?

VS Code’s Hot Exit backs up unsaved changes so they can be restored after an unexpected close. Configure this behavior with files.hotExit. Hot Exit is recovery support; deliberate saving remains the reliable way to write the current contents to disk.

Common save problems and fixes

The tab still shows a dot

Cause: The editor has changes that have not been written. Fix: Press the platform shortcut, run File: Save from the Command Palette, and check whether the file is read-only or whether a save prompt is open behind another window.

Save is disabled or says the file is read-only

Cause: The operating system permissions, source-control checkout, or file attributes prevent writing. Fix: Save a copy with Save As, change the file permissions or checkout state outside VS Code, then reopen the writable file. Do not overwrite a protected system file unless you understand the consequence.

“Unable to write file” appears

Cause: The directory does not exist, the path is unavailable, the file is locked, or the disk is full. Fix: Confirm the folder still exists, check free space, close programs that may hold the file, and use Save As to a writable local folder.

Auto Save does not run

Cause: files.autoSave is off, a language or workspace setting overrides the user setting, or the editor is not losing focus as expected. Fix: Inspect the setting at all scopes in Settings, choose a supported mode, and verify files.autoSaveDelay for afterDelay.

The wrong filename or extension was saved

Cause: Save As used an unintended path or the filename omitted its extension. Fix: Run Save As again, confirm the complete path and extension, and check the Explorer entry before continuing.

Changes disappeared after a crash

Cause: The latest edits were never explicitly saved and recovery data may be incomplete. Fix: Reopen the folder and inspect restored editors, then save recovered content immediately. Enable an Auto Save mode if losing unsaved edits is costly.

Reliable saving workflow

  1. Open the project folder, not just an individual file, so relative paths and workspace settings are consistent.
  2. Save before running formatters, refactors, builds, or external tools.
  3. Use Save All before switching branches or closing a workspace.
  4. Use Git or another version-control system for history; saving alone does not create a recoverable revision.
  5. Use Auto Save when you value continuous writes, and keep explicit saves in your normal workflow before risky operations.

Or skip the browser setup

If your workflow also needs screenshots of saved documentation, previews, or rendered pages, ScreenshotNeo provides a website screenshot API. It removes cookie banners, newsletter popups, and chat widgets before the shot. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and each response identifies the page verdict and billing result. Its MCP server lets Claude, Cursor, and other MCP clients take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Create a free ScreenshotNeo account and get 1,000 screenshots each month with no card.

FAQ

What is the save shortcut in VS Code?

Use Ctrl+S on Windows/Linux and Cmd+S on macOS.

How do I save a file under a new name?

Use File > Save As, Ctrl+Shift+S on Windows/Linux, or Shift+Cmd+S on macOS.

How do I save all open files?

Run Save All, use Ctrl+K then S on Windows, or Option+Cmd+S on macOS.

Does Auto Save replace manual saves?

It can write changes automatically, but an explicit save is still useful before closing, switching branches, or running a risky operation.

Can VS Code recover an unsaved file?

Hot Exit can restore unsaved changes after an unexpected close, but it is not a substitute for saving deliberately.