Ferrum Marketplace

Format on Save

Vyloxi ✔ · ⬇ 0 installs · Formatters

Runs a formatter (Prettier, rustfmt, gofmt, black, shfmt...) on a file each time you save it. Off until you turn it on.

vyloxi.format-on-save Download .fext

In Ferrum open Extensions in the sidebar, search for Format on Save and press Install. Or use Extensions: Install from File with the downloaded file.

Format on Save

When you save a file, this types the formatter command for that file type in the terminal, for example npx prettier --write "src/app.ts". It is off by default. Turn it on with formatOnSave.enabled (or the command, for this session only). Format This File Now does it once.

Built in formatters

Prettier for JavaScript, TypeScript, JSON, CSS, SCSS, HTML, Markdown, YAML, Vue and Svelte; rustfmt; gofmt -w; black; shfmt -w; terraform fmt; dart format; ktlint -F; php-cs-fixer fix. They must be installed. Change or add any with the formatOnSave.commands setting (a JSON object, with {file} where the path goes).

Things to know

  • The command is typed into the terminal that is open. Do not use this while a program that reads keys is running there (a server's prompt, a REPL, a pager): the command would be typed into it.
  • Formatting rewrites the file on disk. The same file is not formatted twice within 4 seconds.
  • Paths with quotes, $ or backticks are skipped.

Permissions

terminal. It does not read any file.