Skip to content

Repository files navigation

Auto Save After Delay

CI

A focused Sublime Text 4 package that saves a file after editing has stopped for a configurable delay. It provides the same core behaviour as VS Code's files.autoSave: afterDelay and Zed's autosave.after_delay, without a runtime dependency.

The default delay is five seconds. The package applies to Markdown, Plain Text, and configured file extensions. It never saves scratch, read-only, invalid, or unnamed buffers.

Background

I built this after writing a Markdown article in Sublime Text and realizing the file had never been saved. I like Sublime because it stays fast and out of the way, but for writing I missed the delayed autosave behaviour built into VS Code and Zed: stop typing, wait a few seconds, then save.

I had already built MarkdownGlance to improve another part of the same writing workflow. This package came from the same habit — when a small friction interrupts real work, understand it and build the smallest tool that removes it. I'm building independent products and sharing these practical tools as part of that journey.

Existing alternative

Package Control already includes James Zhang's longstanding auto-save package. It supports a configurable debounce delay, all-file and current-file modes, and optional backup files. It is the better choice if those broader controls are what you need.

This package is a smaller Sublime Text 4 implementation shaped around my Markdown writing use case: enabled by default, scoped to writing files by default, five-second idle delay, explicit unsafe-buffer checks, and automated tests. Because the core behaviour already exists in Package Control, this project intentionally remains a GitHub installation rather than adding a near-duplicate listing there.

Installation

If you do not use Git

You can install the package by hand instead. No command line is needed.

  1. Go to the latest release.
  2. Under Assets, click Source code (zip) to download the ZIP file.
  3. Unzip it. You will get a folder with a version number in its name, such as sublime-auto-save-after-delay-1.0.
  4. Rename that folder to AutoSaveAfterDelay. The name must be exactly this, or Sublime Text will not load the package.
  5. In Sublime Text, open Preferences > Browse Packages.... A file manager window will open.
  6. Move the AutoSaveAfterDelay folder into that window.
  7. Restart Sublime Text.

Now open a Markdown file and make a change. After you stop typing for five seconds, the package will save the file automatically.

To update later, delete the old AutoSaveAfterDelay folder and repeat these steps with the new release.

Symlink for local use or development

Open Preferences > Browse Packages..., then symlink this checkout into that directory using the package name AutoSaveAfterDelay.

Linux example:

git clone https://github.com/feibuilds/sublime-auto-save-after-delay.git
ln -s "$(pwd)/sublime-auto-save-after-delay" \
  ~/.config/sublime-text/Packages/AutoSaveAfterDelay

Copy into Packages/User

For a minimal personal installation, copy the plugin and settings file into the User directory shown by Preferences > Browse Packages...:

cp AutoSaveAfterDelay.py AutoSaveAfterDelay.sublime-settings \
  ~/.config/sublime-text/Packages/User/

The full package-directory installation is recommended because it also adds a settings menu. This package is distributed through GitHub rather than Package Control; see Existing alternative for the Package Control option.

Sublime normally reloads changed plugins automatically. If needed, use **Tools

Developer > Reload Plugins** or restart Sublime Text.

Configuration

Open Preferences > Package Settings > Auto Save After Delay > Settings. Sublime opens the defaults beside your user override:

{
    "enabled": true,
    "delay_ms": 5000,
    "extensions": ["md", "markdown", "mdown", "mkd", "txt"]
}
  • enabled: enables or disables delayed autosave globally.
  • delay_ms: idle time before saving, in milliseconds. Negative values become zero; invalid values fall back to 5000.
  • extensions: additional case-insensitive extensions, with or without a leading dot. A single string is also accepted.

Markdown and Plain Text syntax buffers are eligible independently of the extension list. Source-code buffers are ignored unless their extension is explicitly configured.

How it works

Each modification increments a generation token and schedules a timer. A later modification changes the token, so every older timer becomes a no-op. Only the latest timer can request a save.

The timer moves back to Sublime's main thread before running the normal save command. Immediately before saving, the package checks the current token, settings, eligibility, safety conditions, and dirty state again.

Development

Run the dependency-free tests with:

python -m unittest discover -s tests -v

The test suite covers debounce invalidation, delay handling, syntax and extension filtering, dirty-state rechecks, view closure, disabling, and unsafe buffers. GitHub Actions runs it across Linux, macOS, and Windows on Python 3.8 and a current Python version. See CONTRIBUTING.md.

License

MIT

About

A small delayed autosave plugin I built for writing Markdown in Sublime Text 4

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages