Using Source Windows in the RStudio IDE

Follow

The RStudio IDE's Source Windows allow you to edit files outside the main RStudio window. This is useful for splitting your work among multiple monitors, or devoting more space to your editor.

Creating Source Windows

There are two ways to open a new source window:

Pop out an editor: click the Show in New Window button in any source editor tab.

Tear off a pane: drag a tab out of the main window and onto the desktop; a new source window will be opened where you dropped the tab.

You can have as many source windows open as you like.

Managing Documents and Source Windows

Each source window has its own set of tabs; these tabs are independent of the tabs in RStudio's main source pane.

To return a document to the main window, click the Return to Main Window button on the editor toolbar. 

To move a document to a different source window, grab its tab and drag it into the window's tab bar.

You can also use this method to return documents to the main source pane.

It's not currently possible for a document to exist in multiple source windows at once, so there's no gesture that "duplicates" a document in this way. 

Navigating to Source Windows

The easiest way to jump to a source window is to use the global Go To File/Function tool (Ctrl + .). Begin typing the name of the file you want to navigate to; when it appears, select it and press Enter. 

When a document is open in a source window, RStudio will jump to that window whenever you navigate to the document, or to a symbol in the document.

You can also use the shortcut Ctrl+1 to go to the last source window that had focus (which may be the main RStudio source pane).

Source Windows on RStudio Workbench / RStudio Server

Source windows on RStudio Workbench (previously RStudio Server Pro) and RStudio Server Open Source behave much as they do in RStudio Desktop, with one primary difference: 

When you navigate to a file, in any way (e.g. jumping to a definition), that file will be opened in the current window; if the file was already opened in a different window, it will be closed there first. 

 

Comments

  • Avatar
    tal ram

    hi,
    when i'm using a source window and i'm trying to debug a function the shortcut keys doesn't work...
    if i want to execute the next line and try to click F10 nothing happens...
    i need to go to the main rstudio window and click on the button...

    are you aware of this? is it solvable?

    thank you

  • Avatar
    Cody Likavec

    Hello,

    Is there a way to retrieve closed source windows? I created a source window to write code back and forth between the Rstudio Source Window and a Popped-Out window. At one point, I believe I hit the X button to close the Popped-Out window that was not saved.

    I wasn't prompted to save or asked if I wanted to close the tab. It just disappeared. Is there ANY way to get that window back?

  • Avatar
    Vilmantas Gegzna

    When focus is in Source Window user defined shortcuts do not work. @tal ram mentioned this problem, and I would like to know if problem is solvable.

    I also noticed, that when focus from Source Window is moved to Console (and I write something to console), the shortcut key combination which calls "insert at cursor position"-like add-in (as in this example: http://rstudio.github.io/rstudioaddins/#running-addins) insert symbols to Source Window (expected to insert to Console) at position where the cursor was before moving the focus. When focus is moved from Editor's window to Console, user defined "insert" shortcuts work as usual.

    version R version 3.3.0 (2016-05-03)
    system x86_64, mingw32
    ui RStudio (0.99.902)

  • Avatar
    Jason Bintz
    Edited by Jason Bintz
  • Avatar
    Jason Bintz

    Bug Report

    I use the latest version of RStudio. I have two (2) recurring issues when working with new or "pop-out" source windows:

    1. When I "pop" the window back into the main window, strings of stray symbols show up in my script. In particular, pipes (%>%) and assignments (<-).

    2. It seems that changes to the popped window are sometimes not saved. More specifically, the script in question seems to go back to the previously saved version. Luckily, I have been able to catch this with version control, but it makes me wary of using this (otherwise very useful) feature.

  • Avatar
    Jason Bintz

    Bug Report

    I use the latest version of RStudio. I have two (2) recurring issues when working with new or "pop-out" source windows:

    1. When I "pop" the window back into the main window, strings of stray symbols show up in my script. In particular, pipes (%>%) and assignments (<-).

    2. It seems that changes to the popped window are sometimes not saved. More specifically, the script in question seems to go back to the previously saved version. Luckily, I have been able to catch this with version control, but it makes me wary of using this (otherwise very useful) feature.