Useful keyboard shortcuts

Evan C. Mascitti


Keyboard shortcuts make life easy

I love removing friction from my daily workflow. I often don’t realize what a pain something is until I no longer have to to do it.

A great example is clicking vs. typing. If you have to stop what you are doing, change the window you are using, and use the mouse to navigate to a new task, it distracts your focus and puts undue strain on your eyes from having to change focus so frequently. That’s why I have come to appreciate keyboard shortcuts.

Here are a few great keyboard shortcuts in RStudio. There are a ton of others; there’s even a keyboard shortcut to view the keyboard shortcuts! (It’s Alt + Shift + K)

R Studio hotkeys

1. Ctrl + Shift + m: Insert pipe operator.

It took me a while to warm up to this one, because it’s already part of the keyboard and only requires two fingers, since it consists of just two characters. However I switched to this one recently and it’s way easier.

2. Ctrl + 1 or 2: Move focus to source or editor pane

Lots of times I jump between the source and console If I just want to run a piece of code quickly to test it, I’ll use the console. This keeps my source from getting too cluttered, which is apt to happen. There are actually over a dozen variants on this hotkey because you can also move the focus to any tab or subpane inside the two other main panes. Ctrl + 5 zooms to the files tab, and Ctrl + 3 shows the help. Finally, to zoom any of these to the full extent of your R Studio window, just add Shift to the sequence.

one shortcut I would like to see implemented is enclosing a selection of text inside single backticks. That is useful for writing inline R expressions, as well as annotating the text as code (useful for writing documentaion in a README file, a reprex, or any post that involves discussing code (like this one!). Plus the backtick key is all the way at the top left corner of the keyboard and I often hit 1 instead by accident, further breaking up the flow.

3. F2 Browse source code of any function

It really is just one key. Looking over source code helps me understand what somebody eles’s functions are supposed to be doing, and gives me ideas for how to improve my own functions. I used to go all the way to GitHub, search for the relevant repo, open the .R file and scroll through the function of interest. Then I learned you can just type the function name (without parentheses) in the console, which opens a new tab in R Studio showing the source code…..but this shortcut takes it a step further. Next time you want to understand how a function works “under the hood” (whether it’s somebody else’s or your own!) just press F2.

Windows hotkeys

John Kaminski posted about keyboard shortcuts earlier in 2020 with the hashtag #CoronaShortcuts:

I thought that was a cool idea, and while reading that thread I learned a few new ones that I had never heard of. Here are some of my other favorites:

Program/environment Description Hotkeys
Windows Screen-grab a portion of current window Windows + Shift + S
Windows Navigate through file explorer Alt + up / down / left / right
Windows Open file explorer Windows + Shift + S
Windows View Desktop Windows + d
Windows Maximize window Windows + up
Windows Minimize window Windows + down
Adobe Illustrator F6 open color panel

The moral of the story is that you should definitely learn keyboard shortcuts, and (if the program you’re using allows), create new ones for things you do often.