Manage RStudio preferences and addin shortcuts
The {rstudio.prefs} package provides a programmatic interface for working with RStudio preference files to modify settings and addin keyboard shortcuts without using point-and-click option menus. This is useful for teams and individuals working across multiple devices who want a unified experience and for enforcing best practices. The package also exposes settings not available in the Global Options dialog.
Install {rstudio.prefs} from CRAN with:
install.packages("rstudio.prefs")Install the development version of {rstudio.prefs} from GitHub with:
# install.packages('devtools')
devtools::install_github("vdwulp/rstudio.prefs")Update the RStudio preferences. A full listing of preferences is available in the RStudio documentation.
library(rstudio.prefs)
use_rstudio_prefs(
always_save_history = FALSE,
save_workspace = "never",
load_workspace = FALSE,
rainbow_parentheses = TRUE,
busy_exclusion_list = list("tmux", "screen")
)
#> √ Downloading list of available RStudio settings
#>
#> == Updates ==================================================
#> - always_save_history [TRUE --> FALSE ]
#> - save_workspace [ask --> never ]
#> - load_workspace [TRUE --> FALSE ]
#> - rainbow_parentheses [FALSE --> TRUE ]
#> - busy_exclusion_list [tmux --> tmux, screen]
#>
#> Would you like to continue? [y/n] yAdd secondary repositories to the ROpenSci and username R-Universes. This is also helpful for adding secondary RStudio Package Manager repositories.
use_rstudio_secondary_repo(
ropensci = "https://ropensci.r-universe.dev",
username = "https://username.r-universe.dev"
)
#> == Updates ==================================================
#> - ropensci [* --> https://ropensci.r-universe.dev]
#> - username [* --> https://username.r-universe.dev]
#>
#> Would you like to continue? [y/n] yUse use_rstudio_keyboard_shortcut() to programmatically add or remove keyboard
shortcuts for add-ins. To remove a shortcut, pass NULL instead of a function.
use_rstudio_keyboard_shortcut(
"Ctrl+Shift+/" = "rstudio.prefs::make_path_norm"
)
#> == Updates ==================================================
#> - Ctrl+Shift+/ [* --> rstudio.prefs::make_path_norm]
#>
#> Would you like to continue? [y/n] y
#> √ File 'C:/Users/username/AppData/Roaming/RStudio/keybindings/addins 2026-08-30.json' saved as backup.
#> √ File 'C:/Users/username/AppData/Roaming/RStudio/keybindings/addins.json' updated.
#> * Restart RStudio for updates to take effect.As shown in the output RStudio needs to be restarted for keyboard shortcut changes to take effect.
{rstudio.prefs} was originally created and developed by Daniel D. Sjoberg. Maintenance was transferred to S.A. van der Wulp starting with v0.2.0.
