0

In RStudio it´s possible to autoformat R Code with CTRL+SHIFT+A (e.g. see this answer). Now my question is, how to autoformat javascript code in RStudio (e.g. if you are working on a shiny app).

Manuel
  • 2,334
  • 4
  • 20
  • 36
  • Auto-formatting of JavaScript code has not yet been implemented in RStudio -- you could consider filing a [feature request](https://github.com/rstudio/rstudio/issues). – Kevin Ushey Feb 25 '19 at 06:33

1 Answers1

0

The prettifyAddins package I've just made provides two RStudio addins for JavaScript files and more: an addin which only reindents the code and an addin which prettifies the code, e.g. it adds semi-colons when they are missing. I will submit it to CRAN soon.

enter image description here

Update

I updated prettifyAddins. It has now addins using the V8 package, and Shiny is not used for these addins, the prettified code directly replaces the current code.

Another possibility is my (freshly built) package aceEditor. It opens the Ace editor in the viewer pane of RStudio:

enter image description here

This provides a second source editor in RStudio. And many languages are supported.

Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225