Skip to contents

Overview

addin.tools is a helper layer for RStudio addin packages. It focuses on editor context, selection ranges, text extraction, and text mutation helpers.

Helper families

Common task patterns

Insert a wrapper around the current selection

context <- rs_get_context()
selected_text <- rs_get_selection_text(context = context)

rs_replace_in_selection(
  replacement = paste0("<kbd>", selected_text, "</kbd>"),
  keep_selected = TRUE,
  selection = "first",
  context = context
)

Insert a small helper at the cursor

context <- rs_get_context()

rs_insert_text(
  text = "message(\"Hello\")",
  context = context,
  spaces = FALSE
)

Select a block of rows before formatting

context <- rs_get_context()

rs_select_rows(
  first = 10,
  last = 14,
  context = context
)

Migration notes

  • Use is_visual_editor() in new code.
  • is_rmd_visual_mode() is retained as a deprecated wrapper for downstream compatibility.
  • When adding new helpers, prefer a small focused API and add regression tests around selection and mutation behavior.

Release notes for maintainers

  • Use the release prep script under data-raw/release-prep.R for the standard release sequence.
  • Run data-raw/revdep-smoke-check.R before tagging when downstream packages need a compatibility smoke test.
  • Use the CRAN checklist under .github/cran-submission-checklist.md before tagging a release.