Christian König Profile picture
Data Science | Sustainability | Biodiversity

Apr 8, 2022, 7 tweets

I've been using #R and @rstudio for years to tackle all kinds of data and coding problems. Here are some of my favorite shortcut keys to improve productivity and make your life easier. (1/7)

Insert pipe - The pipe operator is everywhere in modern R code but typing it can be tedious. Use 𝗖𝘁𝗿𝗹 + 𝗦𝗵𝗶𝗳𝘁 + 𝗠 to build your pipes quicker. (2/7)

Comment/uncomment blocks - Sometimes you want to quickly disable a chunk of code without deleting it. Use 𝗖𝘁𝗿𝗹 + 𝗦𝗵𝗶𝗳𝘁 + 𝗖 to (un)comment entire code blocks. (3/7)

Multi-cursor editing - Repetetive code is quickly written but hard to edit. Use 𝗖𝘁𝗿𝗹 + 𝗔𝗹𝘁_𝗹𝗲𝗳𝘁 + 𝗠𝗼𝘂𝘀𝗲_𝗹𝗲𝗳𝘁 to spawn multiple cursors. Hold 𝗔𝗹𝘁_𝗹𝗲𝗳𝘁 + 𝗠𝗼𝘂𝘀𝗲_𝗹𝗲𝗳𝘁 and drag your mouse to edit consecutive lines at the same position. (4/7)

Move selection - Instead of copy/pasting code chunks you can simply move them up and down by pressing 𝗔𝗹𝘁_𝗹𝗲𝗳𝘁 + 𝗨𝗽/𝗗𝗼𝘄𝗻. (5/7)

Rename in scope - Sometimes you want to use a different variable name or call a different function in certain code sections. Search and Replace can be dangerous in these situations. It's safer to use 𝗖𝘁𝗿𝗹 + 𝗦𝗵𝗶𝗳𝘁 + 𝗔𝗹𝘁_𝗹𝗲𝗳𝘁 + 𝗠 to rename in scope. (6/7)

Find in files - An absolute killer feature of RStudio when working on larger projects with multiple files. Use 𝗖𝘁𝗿𝗹 + 𝗦𝗵𝗶𝗳𝘁 + 𝗙 to search (and even replace) keywords across your project. (7/7)

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling