Skip to contents

Lifecycle: experimental

Lifecycle: experimental

The functions on this page overwrite files that belong to you: RStudio preferences, keybindings, and spellcheck dictionaries. They are experimental and their preset contents change between releases. Back-ups are made by default — keep it that way until you are sure.

Preferences

RStudio’s Custom Settings guide documents the point-and-click interface for these preferences. The CRAN package rstudio.prefs, by S.A. van der Wulp and Daniel D. Sjoberg, is a broader alternative for programmatic preference-file and addin-shortcut management.

Four presets are available:

to What it does
"rstudio-default" RStudio’s own defaults
"bio-default" course defaults, light theme
"bio-dark-blue" course defaults, Cobalt theme
"bio-black" course defaults, Chaos theme
bio::rstudio_reset_user_settings(to = "bio-default")

backup = TRUE (the default) copies the current rstudio-prefs.json into the backup directory first, and ask = TRUE asks for confirmation. An automated run needs both switched off:

bio::rstudio_reset_user_settings(to = "bio-default", backup = TRUE, ask = FALSE)

What happens inside RStudio versus outside it

The two situations genuinely differ, and it is worth knowing which one you are in:

  • Outside RStudio (Rscript, a terminal, CI) the presets are merged straight into rstudio-prefs.json. The write is transactional: if any preset fails, the original file is restored byte-for-byte, or removed again if there was no original.
  • Inside a running RStudio session the presets go through rstudioapi::writeRStudioPreference(). RStudio owns the file and re-persists its in-memory state, so bio does not delete or roll back the file — doing so would have no effect anyway.

A preference key that your RStudio version does not recognise is reported in a single warning and skipped; the remaining keys are still applied. Only an unreadable preset file aborts the operation.

Note

ask = TRUE additionally issues RStudio’s clearUserPrefs command. That command opens its own confirmation dialog which cannot be suppressed, so it is deliberately limited to the interactive path.

Comparing before you change anything

bio::rstudio_compare_user_settings(to = "bio-default")
bio::rstudio_compare_user_settings(to = "rstudio-default", output = "verbose")

source chooses where the “current” values come from:

  • "auto" (default) — live values inside RStudio, the file otherwise;
  • "live"rstudioapi, and therefore a running session;
  • "file" — always rstudio-prefs.json.

Because that file only stores values you changed from RStudio’s built-in defaults, the file-based comparison fills in unset keys from your local RStudio installation’s preference schema when it can find it.

Keybindings

See Posit’s guide to custom keyboard shortcuts, including conflict handling and the locations of the JSON binding files.

bio::rstudio_reset_keybindings(to = "bio-default")
bio::rstudio_reset_keybindings(to = "rstudio-default", backup = TRUE)

This is a plain file copy, so it works without a running RStudio session. Restart RStudio afterwards, or call bio::rstudio_reload_ui().

Spellcheck dictionaries

Posit’s Spelling settings guide explains how RStudio uses custom dictionaries. The GitHub-only wellspell.addin provides interactive spellchecking that can use the dictionaries installed here.

Inside RStudio this delegates to the IDE’s own downloader. Outside RStudio it downloads Posit’s dictionary archive itself, retrying interrupted transfers and falling back to the system curl command. Before extracting, the archive is checked: it must contain the expected dictionary files, and any entry that would write outside the target directory is refused.

The function invisibly returns TRUE or FALSE, so you can branch on it:

ok <- bio::rstudio_install_spellcheck_dictionaries()
if (!ok) message("Dictionaries were not installed.")

Important

secure = FALSE fetches the archive over an unencrypted connection and extracts it into your configuration directory. It warns, and you should not need it.

Back-ups

Every destructive helper writes a timestamped copy first. To find them:

Restoring is a manual file copy — deliberately, so that nothing overwrites your current state without you asking.

The files themselves

Open them instead with bio::open_rstudio_config_file(), bio::open_rstudio_keybindings_dir(), bio::open_rstudio_snippets_dir(), or bio::open_r_environ().

The configuration directory (%APPDATA%/RStudio on Windows, ~/.config/rstudio elsewhere) holds preferences, keybindings, snippets, and dictionaries. The internal state directory (%LOCALAPPDATA%/RStudio, ~/.local/share/rstudio) holds session state and is not something bio rewrites.

See also Posit’s guides to RStudio settings, code snippets, and editor themes.