r-exec

Send R code to various R consoles

pimentel

18,023

16

0.5.0

MIT

GitHub

r-exec

Send R code from Atom to be executed in R.app, Terminal, iTerm, or a web browser running RStudio Server on Mac OS X. The current selection is sent or in the case of no selection the current line is sent.

Installation

apm install r-exec

or

Search for r-exec within package search in the Settings View.

Configuration

Keybindings

While cmd-enter is bound to sending code in the package, it is also annoyingly bound to entering a new line by default in atom. In order to make it work, you must add the following binding in ~/.atom/keymap.cson:

'atom-workspace atom-text-editor:not([mini])':
  'cmd-enter': 'r-exec:send-command'

Behavior

All configuration can be done in the settings panel. Alternatively, you can edit your configuration file as noted below.

In your global configuration file (~/.atom/init.coffee), you may set the following variables:

The default configuration looks like this:

atom.config.set('r-exec.whichApp', 'R.app')
atom.config.set('r-exec.advancePosition', false)
atom.config.set('r-exec.skipComments', true)
atom.config.set('r-exec.focusWindow', true)
atom.config.set('r-exec.notifications', true)
atom.config.set('r-exec.smartInsertOperator', true)

Inserting operators

r-exec currently supports inserting the assignment (<-) and pipe (%>%) operators. It tries to be smart by looking if there is whitespace to the left or the right of the cursor. If there is already whitespace it will not insert additional whitespace. Otherwise, it will insert whitespace. This can be disabled in the settings tab (Smart Insert Operator).

Notes about iTerm

The iTerm2 Applescript API recently changed as of version 3.0.0. Older versions of iTerm2 (< 3.0.0) are supported using mode iTerm. Newer versions of iTerm2 (>= 3.0.0) are supported using mode iTerm2.

Usage

Sending code

myFunction <- function(x) {
  # my code goes here
}

Inserting operators

Notes

It is currently Mac-only because these things are easy to do with AppleScript. Any help on the Windows or Linux side would be great.

TODO