|
7 | 7 | --- |
8 | 8 |
|
9 | 9 | Air is first and foremost a formatter of R code. |
10 | | -On this page, you'll find details about what a formatter is, why you'd want to use one, and you'll learn about how Air makes decisions on how to format your R code. |
| 10 | +On this page, you'll find details about what a formatter is, why you'd want to use one, and you'll learn about features that help you anticipate how Air will format your R code. |
11 | 11 |
|
12 | 12 | # What's a formatter? |
13 | 13 |
|
@@ -92,7 +92,20 @@ By agreeing to use a formatter in a project, collaborators no longer have to dis |
92 | 92 | Code sent to you by a colleague will adhere to the standards that you're used to. |
93 | 93 | Code review no longer has to be about style nitpicks and can focus on the substance of the changes instead. |
94 | 94 |
|
95 | | -# How does Air decide how to format your code? |
| 95 | +# When does a formatter run? |
| 96 | + |
| 97 | +The most convenient way to run a formatter is when you save a file. |
| 98 | +Most editors don't enable this by default, so check out the [Editors](editors.qmd) section to learn how to configure your editor to format on save. |
| 99 | +Once enabled, your code will be reformatted every time you save! |
| 100 | +This prevents your code from ever diverging from the standards set by Air. |
| 101 | +
|
| 102 | +Air also provides a [CLI tool](cli.qmd). |
| 103 | +It makes it easy to reformat whole directories, such as an R project or package, using a single call to `air format <path>`. |
| 104 | +
|
| 105 | +Note that in both of these cases, the formatter will only run if your code is syntactically correct. |
| 106 | +If the formatter is seemingly no longer working, check your code for syntax errors. |
| 107 | +
|
| 108 | +# Persistent line breaks |
96 | 109 |
|
97 | 110 | Air tries to strike a balance between enforcing rigid rules and allowing authors some control over the layout. |
98 | 111 | Our main source of styling rules is the [Tidyverse style guide](https://style.tidyverse.org), but we occasionally deviate from these. |
@@ -605,17 +618,3 @@ skip = ["graph_from_literal"] |
605 | 618 |
|
606 | 619 | One particularly common use of this is `skip = ["tribble"]`, which you can use to avoid formatting of all `tibble::tribble()` calls. |
607 | 620 | In the long term, Air may provide more sophisticated tooling for formatting using a specified alignment. |
608 | | - |
609 | | -# When does a formatter run? |
610 | | - |
611 | | -The most convenient way to run a formatter is when you save a file. |
612 | | -Most editors don't enable this by default, so check out the [Editors](editors.qmd) section to learn how to configure your editor to format on save. |
613 | | -Once enabled, your code will be reformatted every time you save! |
614 | | -This prevents your code from ever diverging from the standards set by Air. |
615 | | - |
616 | | -Air also provides a [CLI tool](cli.qmd). |
617 | | -It makes it easy to reformat whole directories such as an R project or package. |
618 | | -If you're incorporating Air into an existing project, you may want to use the CLI tool to run air format once on the entire project, commit those results, and then rely on per-file format on save from there on out. |
619 | | - |
620 | | -Note that in all of these cases, the formatter will only run if your code is syntactically correct. |
621 | | -If the formatter is seemingly no longer working, check your code for syntax errors. |
0 commit comments