openeditorcode.devFIELD MANUAL / 0.2.41Español
formatting.md DOCUMENTATION

14 — Reference

Formatting

Built-in Prettier and external executables, with selection and saving rules.

v0.2.41Source review ·
On this page

Format a document

  1. Open a project file in source and press Alt+Shift+F or Format document in the palette.
  2. OEC selects byExtension or defaultFormatter. none skips formatting; prettier receives content, filepath and configured options.
  3. Apply the result only if path and content still match on completion. Save afterwards with Ctrl+S.

Options and format on save

Defaults use Prettier for JavaScript, TypeScript, JSON, CSS, HTML, SVG, Markdown and YAML. SVG forces the HTML parser to handle it as markup. Five options are exposed: printWidth, tabWidth, useTabs, semi and singleQuote.

formatOnSave applies during normal saving, only to project files in source. A formatter error does not prevent that save from continuing. Close/quit confirmation paths skip formatting.

Register an external formatter

Declare it globally only. The process receives text on stdin and must return the full document on stdout; stderr is used for diagnostics. It runs without a shell, with a timeout, inheriting process environment and cwd.

  • Map .txt to myFormatter in global editor.formatting.byExtension. The executable’s extensions list must support that extension.
  • All four fields are required. There is no automatic path interpolation or sandbox. This does not declare new palette commands.
Illustrative global fragment: replace executable/arguments with your tool’s valuesjson
"formatters": {
  "external": {
    "myFormatter": {
      "command": "my-formatter",
      "args": ["--stdin"],
      "extensions": [".txt"],
      "timeoutMs": 5000
    }
  }
}

Chapter sources

Links pinned to the reviewed commit; they do not follow main.

Static documentation · ES / ENView coverage ↗