Batch reindenting



Is there a way to apply the rstudio indenting routine (ie, Ctrl + I or Code / Reindent Lines) on an entire folder of R files rather than having to open each file and using the routine manually?


I think the styler package would be able to help in this regard.



Thanks for the suggestion. Not exactly what I am looking for as the style_active_file/dir routine also refactors the code (eg, line break inserts).

I switch between multiple IDEs which each have a different behavior in terms of indenting (especially with the "({ })" structure which are widely used in Shiny code)... Re-indent is all I need :smiley:


Gotcha -- unfortunately, RStudio currently doesn't expose an easy way to access its code indenter for use outside of RStudio.

I wonder if the styler package could be extended to handle cases like this -- just re-indent code without changing any other structure?