Programmable shortkeys

Is there any way to assign R code to RStudio IDE shortkeys. For example, to source a specific script in the current session each time CTRL + Shift + S is pressed?

I know that there is a "Source on Save" option, but the question here is more general.

Currently, the only solution I can think of is to set the Project option to "package", which enables the CTRL + SHIFT + L shortkey to execute devtools::load_all(".").

Then in .Rprofile I change the functionality of devtools::load_all("."):

rlang::env_binding_unlock(env = asNamespace('devtools'))
assign('load_all', function(x) source('some_script.r'), envir = asNamespace('devtools'))
rlang::env_binding_lock(env = asNamespace('devtools'))

Now when I press CTRL + SHIFT + L, some_script.r gets sourced.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.