user2957945
user2957945

Reputation: 2413

How to set Crtrl+r to execute commands in Rstudio

How can I set RStudio to use Ctrl+R (in addition to Ctrl+Enter) to execute commands?

https://community.rstudio.com/t/bring-ctrl-r-back/1846 suggests editing the "rstudio_bindings.json" file, but I can't find the file.

https://support.rstudio.com/hc/en-us/articles/206382178-Customizing-Keyboard-Shortcuts gives instructions to add using from the menu options. I tried to add "Ctrl+Enter|Ctrl+R" as suggested in the first link but this is not accepted. At the bottom of the page it describes how the bindings are saved at ~/.R/rstudio/keybindings/rstudio_commands.json or ~/.R/rstudio/keybindings/editor_commands.json. I cannot find either of these files.

How can I do this?

R version 3.4.2
RStudio Version 1.1.383
Windows 7

Upvotes: 1

Views: 548

Answers (1)

user2957945
user2957945

Reputation: 2413

Following advice from https://community.rstudio.com/t/bring-ctrl-r-back/1846, you have to edit the file ~/.R/rstudio/keybindings/rstudio_bindings.json with

{
    "executeCode" : "Ctrl+Enter|Ctrl+R"
}

These directories and file already existed on Ubuntu, however, neither the file nor any of the directories existed on my Windows partition. So needed to create the nested directories .R/rstudio/keybindings, and then create the json file shown above, and save it as rstudio_bindings.json.

(aside: Windows didn't like trying to name a new folder of .R (the leading dot gave problems), but you can get round this by naming .R. , as the trailing dot is removed from here )

Upvotes: 2

Related Questions