Ernie
Ernie

Reputation: 1153

Is there R code for moving the focus to the RStudio console?

I am constantly typing into the edit window of RStudio after my code completes execution, when my intention is to provide some input in the console window. Is there R code that could be executed that would automatically move the focus to the console window of RStudio?

Upvotes: 7

Views: 2197

Answers (2)

retodomax
retodomax

Reputation: 615

If you don't look for a shortcut but for code, RStudio has the following command

rstudioapi::executeCommand('activateConsole')

See also RStudio IDE Commands

Upvotes: 4

DanY
DanY

Reputation: 6073

In RStudio, go to the menu: Tools > Global Settings. In Global Settings, choose "Code" on the left and check the box that says "Focus console after executing from source."

If you don't want to change this global option, these keyboard shortcuts can make switching between the console and editor in RStudio much faster:

  • Ctrl+1 moves focus to the source editor
  • Ctrl+2 moves focus to the console

In addition, Alt+Shift+k brings up a list of most keyboard shortcuts

Upvotes: 9

Related Questions