Let's be honest, what keyboard shortcuts in RStudio do you use? What do you remap to other keys?
I would ask what do you wish for, but it's pretty easy to turn any common action/menu button into a keyboard shortcut.
Let's be honest, what keyboard shortcuts in RStudio do you use? What do you remap to other keys?
I would ask what do you wish for, but it's pretty easy to turn any common action/menu button into a keyboard shortcut.
I really don't use very many considering what's possible. I use:
ctrl/cmd + enter - run R code line/block in R console
ctrl+alt+enter - send non-R code to terminal (as of v1.1.3xx)
ctrl+1 - jump to source
ctrl+2 - jump to R console
ctrl+W - close source tab
ctrl+shift+N - new source document
ctrl+shift+C - comment out line
ctrl+shift+R - insert section break (useful with outline enabled)
ctrl+alt+i - insert empty Rmd chunk
alt+-
inserts the <-
(which I like because it adds the spaces for me)
ctrl+shift+M inserts the pipe operator %>%
(so hard to type, such a great shortcut)
ctrl+D deletes entire line (this is usually ctrl+k in other editors but is curiously mapped to Yank line after cursor
in RStudio instead)
That's pretty much all I use other than standard copy/cut/paste/save/open/undo/redo ones. I've used others, but tend to forget them due to lack of use. Anything really useful I'm missing from my repertoire?
I use a lot:
I remap
Novelty bias alert, as I literally only figured this out two days ago, but:
Shift+Tab for snippets in Rmd (same in other source code, but no autocomplete/showing up with the cursor in md)
I somehow missed shift+tab for snippets. I use snippets and have my own, but I always just start typing the snippet name. I'm sure I'm missing out on the ones I can't remember and am going to start using that shortcut.
Ctrl + shift + a to reformat sections alot. Especially during code reviews
Ctrl/cmd + Shift + P to re-run the previous region <- I find myself using this all the time!!
Ctrl / Cmd + Option + P
Cmd + Shift + M
[custom] alt + Left Arrow for assignment operator
Cmd + I
Cmd + Shift + A
Cmd + Shift + C
Does anyone know what Alt+C is mapped to? My R Studio Server somehow catches this shortcut, without seemingly doing anything.
On the Czech keyboard (we have a lot of accented characters, so space is limited) this shortcut is mapped to ampersand (&) which is kind of useful in R, and I am at loss at how to reset the mapping.
On a cheerful note: the person who invented the code snippet r + Shift+Tab in Rmarkdown should be given his weight in gold by some benevolent despot; I don't think I have written a backtick since discovering it.
EDIT: I have found that if I reset the shortcut to execute current RMarkdown code chunk (which was not mapped to Alt+C) I regain the ability to write ampersand character. I have no idea how it works, but I am glad it does.
I think the only shortcut that came premapped that I use is for commenting out chunks of code: Ctrl+Shift+C
I then have three custom mappings which I use all the time:
F3 - Run highlighted code
F4 - Run entire code script
F5 - Knit .Rmd Files
Edit: I came up with these as I was used to SAS Programming before switching most of my efforts to R & RStudio. In SAS, F3 also runs the highlighted code chunk and so it expanded from there based on habit.
Alt + Shift + β/β to duplicate lines (code duplication is to be avoided, but...)
(just discovered Ctrl + Shift + D that does almost the same)
Alt + β/β to move line(s): very often one I've just duplicated, or can be a code chunk, or a single line in a %>%
-line, or reorder my library()
statements, that kind of things
Ctrl + Shift + F to "grep" code in my project (especially in the context of Discerning intra-code dependencies)
F1 for help
F2 for definition
It is more a keyboard shortcut that goes with using RStudio, than a RStudio shortcut, but yesterday I spent a bunch of time mourning that I had not know the keyboard shortcut on a Macintosh for copy the POSIX path of the select file in Finder is Command + Option + c
That is one that would have saved many many hours when writing scripts.
Thanks a bunch. This is super useful!
Besides the shortcuts for running code and building packages, definately f2 (go to function source)
Favourites:
cmd
+ shift
+ M
alt
+ shift
+ T
ctl
+ 2
Cmd + shift + K for markdowns all day
I mapped alt + - to the assignment operator β<-β and it has made life soooo much easier
I use this one a lot. Except I use the default hotkey option + - . I think I use the pipe hotkey the most though, command + shift + m
Ah you know what, I use the default for assignment also I actually meant to say I re-mapped the pipe to command + .
Makes it just that bit faster instead of having to hold down three keys
I see the assigned keyboard shortcuts, but is there a URL for shortcuts that haven't been assigned yet?
I see the list in the IDE itself, but it would be handy to have it on a web page that I can refer to.