# `mix surface.format`
[🔗](https://github.com/surface-ui/surface/blob/v0.12.3/lib/mix/tasks/surface/surface.format.ex#L1)

> #### Formatter Plugin Preferred {: .tip}
>
> To format Surface code using Elixir 1.13 or later, use
> `Surface.Formatter.Plugin`.

Formats Surface `~F` sigils and `.sface` files in the given files and patterns.

```bash
$ mix surface.format "lib/**/*.{ex,exs}" "test/**/*.{ex,exs}"
$ cat path/to/file.ex | mix surface.format -
```

Takes the same options as `mix format` except for `--check-equivalent`.

## Formatting options

Like `mix format`, the Surface formatter reads a `.formatter.exs` file in the
current directory for formatter configuration. The Surface formatter accepts
the same options as `mix format`. Read more about the expected format of
`.formatter.exs` and the shared configuration options
[documented here](https://hexdocs.pm/mix/main/Mix.Tasks.Format.html#module-formatting-options).

The Surface formatter also takes the following two additional options
specified in `.formatter.exs`:

  - `:surface_line_length` overrides `:line_length` only for `mix surface.format`
    (`:line_length` is used otherwise, or defaults to 98)
  - `:surface_inputs` overrides `:inputs` only for `mix surface.format`
    (`:inputs` is used otherwise)

## Task-specific options

The Surface formatter accepts the same task-specific options as `mix format`.
[Read documentation for the options documented here.](https://hexdocs.pm/mix/main/Mix.Tasks.Format.html#module-task-specific-options).

For quick reference, here are some examples of using these options:

```bash
$ mix surface.format --check-formatted
** (Mix) mix surface.format failed due to --check-formatted.
The following files are not formatted:
  * path/to/component.ex
  * path/to/file.sface
```

```bash
$ mix surface.format --dry-run
```

```bash
$ mix surface.format --dot-formatter path/to/.formatter.exs
```

You can also use the same syntax as `mix format` for specifying which files to
format:

```bash
$ mix surface.format path/to/file.ex "lib/**/*.{ex,exs}" "test/**/*.{ex,exs}"
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
