[R-SIG-Mac] Up arrow keys running code from editor

David Winsemius dwinsemius at comcast.net
Tue Oct 29 18:49:42 CET 2013


On Oct 29, 2013, at 7:41 AM, Helen Greatrex wrote:

> Hi,
> 
> I'm a regular R user, but very new to using a Mac computer.
> 
> On my windows system, I used to work in the R editor and highlight a chunk
> of code that I wanted to run, press Ctrl-r to run, then I could use the up
> arrow in the console to run individual lines

In the Mac GUI, my understanding is that you are expected to be editing in a draft document. If you highlight code within the draft, and jointly press <cmd>-<return> you get the block execution. New drafts are created with either the file menu or the "blank-document" icon at the top of the GUI.

> 
> For example I could write this into an editor window
> x <- 2+2
> y <- 6
> z <- 67
> 
> Then I would highlight these lines and run using Ctrl-r, giving this output
>> x <- 2+2
>> y <- 6
>> z <- 67
> 
> I could then press the up arrow twice to select y <- 6, and edit that
> specific line
> 
> In a mac, I have tried to do the same thing, but using Command-enter to run
> the code from the editor window.

The draft document will serve the same purpose.

> However, when I press the up-arrow key,
> it wants to re-run all three lines. e.g. I would see this as the bottom
> line on the console after pressing the up key once

The up-arrow key only recovers the history (lines/chunks) when the focus is the console, not from within an active document window. 

> 
>> x <- 2+2
> y <- 6
> z <- 67
> 
> Is there a way I can turn off this option?  I just want the up and down
> arrow keys in the console to select the history line by line rather than by
> the chunks that I ran from the editor.  e.g. pressing the up-arrow twice in
> the console to give me > y <- 6

If you entered it as a chunk, it will be recovered from the history buffer as a chunk. (You can bring up the R for Mac OS X FAQ from the Help menu.)

You can move to a line (in the editing window) and even without selecting it use cmd-return to run the whole line. (I believe that is what the grey-highlighting is trying to tell you.)

The <Shift>-arrow key combination works in both the editor and the console as it has always worked on a Mac to extend selection.  I doubt that behavior is documented in the FAQ, but it may give you some of the behavior you seek.

I think you will find the <option>-drag behavior to be Mac specific. I was very happy when it's availability was returned to the Mac GUI repertoire.

> from the 
> Alternatively, is there another way/shortcut to achieve the same outcome on
> a mac?
> 
> I apologise for asking such a simple question - I have searched the
> r-sig-mac archive and come up with similar posts but none that answer my
> query, although probably from searching using the wrong terminology.


>  I have looked through preferences and checking clean history doesn't seem to
> work, but I'm sure I'm missing something simple as part of my mac learning
> curve.
> 
> I am running R 3.0.2 GUI 1.62 Snow Leopard build (6558) on OS Mavericks
> 
> Many thanks in advance
> Best wishes
> Helen
> 
> 	[[alternative HTML version deleted]]

This is a plain text mailing list.
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac

David Winsemius
Alameda, CA, USA



More information about the R-SIG-Mac mailing list