I am trying out Positron that builds upon VS studio code to be more data science centric. I am used to coding in R Studio which will automatically indent my code inside of functions and I am used to that look. Is there a way to change how Positron does indenting?
Here is an example:
iris |> #Only function indented
mutate(test= "dog",
test_2 = "cat") #function arguments not indented
iris |>
mutate(test= "dog", #Function arguments indented
test_2 = "cat")
1 Answer 1
The intended way to format R code in Positron is via Air, a new formatter for R. Air comes with Positron (actually, it's bundled inside an extension that comes with Positron). The recommended way to opt in to "format my code with Air every time I save" is to put this in your user-level settings:
{
"[r]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "Posit.air-vscode"
},
"[quarto]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "quarto.quarto"
}
}
You can read more here: <https://posit-dev.github.io/air/editor-vscode.html>