RStudio Shortcuts and Settings

I often get asked about RStudio settings. So that’s why I’ve decided to share my settings and all of my favorite RStudio tricks.
Author

Albert Rapp

Published

June 2, 2024

RStudio is the premier way to write R code. It is very user-friendly as it’s super easy to set up. But it also has a lot of pretty advanced features. In today’s blog post I’ll give you a list of my favorite RStudio tricks and shortcuts. If you want to see detailed explanations, you can check out my video here:

RStudio Theme Setting

  • Use a dark theme for better visibility
  • Enable rainbow parentheses and rainbow indentations to improve code legibility
  • Increase the font size for better readability

RStudio Settings

  • Set up RStudio with the file on the left and the console on the right (as the console is more important than the environment tab for most use cases)
  • Do not save anything into your environment when closing RStudio (Always start with a clean slate to avoid mistakes caused by leftover variables from previous sessions)

Coding Basics

  • Use Ctrl + Shift + M to create a pipe (|>) without typing special characters
  • Use Ctrl + Enter to execute separate lines
  • Use Ctrl + Shift + Enter to execute an entire file
  • Select a specific part of the code and use Ctrl + Enter to execute only the selected portion (useful for debugging pipe chains step by step)
  • Open function documentation with F1
  • Move lines of code with Alt + arrows
  • Indent with Tab and unindent with Shift + Tab
  • Multiple cursors with Alt + click
  • Use Ctrl + 1 and Ctrl + 2 to switch between the console and the current script window (eliminates the need to use the mouse for navigation)

Command Palette and more shortcuts

  • Use Ctrl + Shift + P to execute commands
  • Helpful for using shortcuts that you might have forgotten (like expanding all folds or going to a file)
    • Run all code chunks (Ctrl + Alt + R)
    • Render current document (Ctrl + Shift + K)
    • Restarting R Session (Ctrl + Shift + F10)
    • Styling code with the styler package
    • Running your Golem apps,

Conclusion

Feel free to share your favorite shortcuts, settings, or any other tips I might have missed in the comments below. Have a great day and see you next time. And if you found this helpful, here are some other ways I can help you:


Stay in touch

If you enjoyed this post, then you may also like my weekly 3-minute newsletter. Every week, I share insights on data visualization, statistics and Shiny web app development. Reading time: 3 minutes or less. You can check it out via this link.

You can also support my work with a coffee