Rstudio keyboard shortcut to copy from console to source?

1.2k Views Asked by At

After years of using this site, I'm finally posting my first question!

In RStudio, I often develop a line of code in the console, and then once satisfied, I copy and paste it into my source code. Since I do this many times a day, I thought it would be great if there were a keyboard shortcut.

I don't see anything for this listed in RStudio's keyboard shortcuts (click on Tools -> Keyboard Shortcuts Help). The only way I've figured out to do this via the keyboard is the following:

  1. Type command at console (don't hit Enter)
  2. Ctrl + U (copy line up to cursor)
  3. Ctrl + 1 (switch to source)
  4. Ctrl + Y (paste line)
  5. Ctrl + 2 (switch back to console)

Question: As you can see, this is not much of a shortcut. Any other hacks? Or better yet, is there a way to define RStudio keyboard shortcuts in addition to the ones that are already defined?

Environment:
RStudio version 1.0.44
R version 3.3.2
Mac OSX 10.11.6

0

There are 0 best solutions below