inst/doc/visual-mode.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(rstudioapi)

## ----eval=FALSE---------------------------------------------------------------
# reformat <- function() {
#   id <- rstudioapi::documentId(allowConsole = TRUE)
#   selection <- rstudioapi::selectionGet(id = id)
#   formatted <- styler::style_text(text = selection$value)
#   rstudioapi::selectionSet(value = formatted, id = id)
# }

Try the rstudioapi package in your browser

Any scripts or data that you put into this service are public.

rstudioapi documentation built on Jan. 16, 2026, 5:18 p.m.