Option to retain selection after running selected R code

jkanglim's Avatar

jkanglim

29 Oct, 2012 06:02 AM

A few versions back, RStudio started moving the cursor after running R code from a selection using Cmd+Enter. I think this is a bad choice of default behaviour, and that at least an option should be provided to disable it.

The typical scenario that I use to run R selections is where I want to highlight a particular object, or function to check that it is working as I expected. If it doesn't work, then I want to edit the code under or near the selection. Even if it does work, I often want to tweak the selection and evaluate something else. For example, I might inspect the value of an object passed as an argument and then the next argument and then the whole function call. Essentially, I'm using the script editor like a more full featured command-line. Moving the cursor to several lines away makes this workflow a lot less efficient.

An alternative would be to have another shortcut key that behaves like Cmd+Enter but does not move the cursor.

  1. Support Staff 2 Posted by Josh Paulson on 31 Oct, 2012 09:20 AM

    Josh Paulson's Avatar

    Thanks for the feedback here and we removed the highlighted selection after running Cmd+Enter as continual support queries noted the following:

    1) After running a highlighted selection, users wanted to advance to the next section of code quickly and pressing Cmd+Enter only re-executes the same command leaving the user stuck. Instead, typically pressing Cmd+Enter without a selection will always advance to the next line of code.

    2) Users often reported that they would run a highlighted selection, and then immediately start typing after this (by habit or intuition). This obviously would overrite the current selection and the user might not notice or would then need to undo what was just typed. Either way, the potential to lose code was a undesirable state to leave the user.

    We're not necessarily sold on either way, but obviously don't want to jump back and forth on either method. An option to configure this is possible and we considered this. For now we're awaiting feedback such as this to see what the proper action is.

    Josh

  2. Josh Paulson closed this discussion on 06 Nov, 2012 05:08 PM.

  3. jkanglim re-opened this discussion on 28 Nov, 2012 04:20 AM

  4. 3 Posted by jkanglim on 28 Nov, 2012 04:20 AM

    jkanglim's Avatar

    I strongly encourage you to add an additional shortcut key that runs the current line (if there is no selection) and the selection if there is a selection, without moving the cursor (or without altering the selection if there is a selection). Perhaps something like Cmd+Alt+Enter would be suitable.

    I think both behaviours (i.e., moving the cursor and not moving the cursor after executing a command) have important roles. I imagine it would be a very simple feature to add. It would also make life so much easier for people who want to use the script editor a little bit like a console.

  5. Support Staff 4 Posted by Josh Paulson on 07 Dec, 2012 10:14 PM

    Josh Paulson's Avatar

    Thanks for the followup and I wrote this up as a new feature request.

    Josh

  6. 5 Posted by jkanglim on 09 Dec, 2012 04:47 AM

    jkanglim's Avatar

    Thanks Josh. I think it would be a great feature.

  7. Josh Paulson closed this discussion on 09 Dec, 2012 04:54 AM.

Comments are currently closed for this discussion. You can start a new one.