Sometimes, you deliberately align code to make it more readable.
Until styler 184.108.40.20602 (with
strict = TRUE, e.g. as in
styler_style_file(..., strict = TRUE)), this was formatted as follows:
because no alignment detection was built in. With
strict = FALSE, the spacing would have been kept, however,
strict = FALSE has a number of other implications because it is in general less invasive (e.g. it would not add braces to the following expression, whereas
strict = TRUE would):
Back to the initial topic, styler >= 220.127.116.1103 detects the aforementioned alignment. This vignette describes how an aligned code is defined by styler and gives some examples so users can format their aligned code to match the definition styler uses to ensure their code is not unintentionally reformatted.
If all arguments in the first column are named: Make commas match position vertically and right align everything between commas
If not all arguments of the first column are named: Make all but the first column’s commas match position vertically and right align everything between the commas, except before the first comma on a line, give priority to correctly indent.
By align everything in between the commas, we mean put zero space before a comma and at least one after. Note that the arguments on the first line are ignored when detecting alignment, which is best shown when code is formatted such that no line breaks will be modified by styler (which is the case if all names on the first line are unnamed and all subsequent are named), like here:
Function calls are aligned if all of the following conditions hold (for all but the very first line (i.e.
=(at least one before and after).
f(x, y),. For this reason, the requirements exclude the first column in such cases. The holds example shows that is is possible (but not required) for named arguments to also have the commas separating the first and second column aligned.
Note that the above definition does not check alignment of
=, so styler will treat the following as aligned: