March '17 Tips and Tricks

by Sean Lopp

This month’s Tips and Tricks focus is on file navigation. Many of these tips are straightforward - more tip than trick - but they can save quite a bit of time and frustration.

Open Recent

Please don’t spend time navigating through your folder structure to find a recent project or file.

Go to File/Function

RStudio automatically indexes all open files as well as files in the current project. The index includes function calls and objects within the files. To search the index, enter a search string in the Go to file/function window in the main toolbar or use the keyboard shortcut Ctrl + ..

The search supports fuzzy matching as long as the search string is in the correct order. For example, tiptric will match files and function names like march-tips-and-tricks.Rmd.

Find in File

In addition to the index, RStudio can quickly search the text of any file(s) for a string or regular expression. Open the Find in Files dialogue by navigating through the toolbar Edit -> Find in Files or using the keyboard shortcut Cmd / Ctrl + Shift + F.


Close All and Close All Except Current

If you’re like me, you often end up with a whole bunch of files open and the number of tabs in the source pane causes anxiety. Don’t click through the tabs closing each individually.

Search for a Tab

If you don’t get anxiety from multiple tabs, you may find the keyboard shortcuts for switching between tabs helpful. My favorite is Ctrl + Shift + . which opens a search dialogue for the currently open tabs.

Set Working Directory

Sometimes I find myself inside a file and I have no idea where that file is. In this scenario, I often use the following trick to orient myself:

The other options, To Project Directory and To File Pane Location are also very helpful. These commands do not have key bindings by default, but you can create your own keyboard shortcuts for these actions: Tools -> Modify Keyboard Shortcuts...

File Pane: Go To Working Directory

After mastering tip 5, you can easily navigate from the file pane to the working directory:

File Pane: Go To Project Root Directory

Finally, it is really easy to go to the root of a project directory:

Be sure to follow @rstudiotips for more frequent updates. Tweet us @rstudio if there’s a file navigation trick you wish we’d implement!

Share Comments · · · ·

You may leave a comment below or discuss the post in the forum