Format on Save
pendingby sotayamashita
Run any external formatter (prettier, deno fmt, etc.) on save.
Format on Save
An Obsidian plugin that runs any external formatter on save. Bring your own tool — Prettier, deno fmt, or anything else that accepts a file path.
Features
- Format on save — automatically runs your configured formatter on explicit save (Ctrl+S / Cmd+S). Auto-save does not trigger formatting
- Manual command — "Format current file" available from the command palette
- Any formatter — use whatever CLI tool you prefer with its own config files
Configuration
| Setting | Description | Default | Example |
|---|---|---|---|
| Enable | Toggle format on explicit save (Ctrl+S / Cmd+S) | true | on/off |
| Formatter command | Path to the formatter executable | "" (empty) | prettier, deno, /usr/local/bin/prettier |
| Formatter arguments | Arguments passed before the file path | "" (empty) | --write, fmt |
Examples
Prettier:
- Command:
prettier - Arguments:
--write
deno fmt:
- Command:
deno - Arguments:
fmt
oxfmt:
- Command:
oxfmt - Arguments:
--write
The file's absolute path is appended automatically as the last argument.
Place your formatter's config file (.prettierrc, deno.json, .oxfmtrc.json, etc.) in your vault root or home directory as usual.
Release workflow
Releases are fully automated via release-please.
How to release
- Merge PRs with Conventional Commits into
main - release-please automatically opens (or updates) a Release PR that bumps the version and updates the changelog
- Merge the Release PR — this creates a git tag and GitHub Release
- The publish job builds
main.jsand uploads release assets
sequenceDiagram
participant M as main branch
participant RP as release-please
participant PB as publish job
participant GH as GitHub Release
M->>RP: push with conventional commits
RP->>M: open/update Release PR (bump version + changelog)
M->>RP: merge Release PR
RP->>GH: create git tag + GitHub Release
GH->>PB: release triggers publish job
PB->>GH: upload main.js, manifest.json
PB->>M: commit updated versions.json
Commit conventions
| Prefix | Version bump | Example |
|---|---|---|
fix: | patch (0.0.x) | fix: handle empty files on save |
feat: | minor (0.x.0) | feat: add timeout setting |
feat!: or BREAKING CHANGE: | major (x.0.0) | feat!: change settings format |
Release artifacts
Each release includes:
main.js— bundled plugin codemanifest.json— plugin metadata
Installation
Manual
- Build the plugin:
pnpm install && pnpm run build - Copy
main.jsandmanifest.jsonto<vault>/.obsidian/plugins/fmt-on-save/ - Reload Obsidian and enable the plugin in Settings → Community plugins
Desktop only
This plugin uses child_process.exec to run external commands and is desktop only.
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.