11

Following the instructions here, I've set up a new installation of SublimeText for use with R. I have no other SublimeText plug-ins installed. The keyboard shortcuts that are setup using the instructions in the link above don't work. I've set up my user key binding file as specified in the tutorial.

There are no conflicting key bindings in the 'Default' key bindings file.

Nonetheless, I can execute my R code in REPL by clicking through the menus:

Tools > SublimeREPL > Eval in REPL > Selection (Ctrl+Shift+R)

If I actually press the Ctrl+Shift+R shortcut, nothing happens.

Here's a copy of my user key binding file:

[
// Modified Sublime-REPL keybindings for an "R-friendly" set of shortcuts.
// For more information, see http://tomschenkjr.net/2012/05/17/using-sublime-text-2-for-r/

// Executes a selection of text in REPL, latter only displays code and does not execute
{ "keys": ["ctrl+shift+r"], "command": "repl_transfer_current", "args": {"scope": "selection"}},
{ "keys": ["ctrl+shift+r", "r"], "command": "repl_transfer_current", "args": {"scope": "selection", "action":"view_write"}},

// Executes the entire file (build) in REPL, latter only displays code and does not execute
{ "keys": ["ctrl + f7"], "command": "repl_transfer_current", "args": {"scope": "file"}},
{ "keys": ["ctrl + f7", "r"], "command": "repl_transfer_current", "args": {"scope": "file", "action":"view_write"}},

// Executes line(s) of text in REPL terminal, latter only displays code and does not execute
{ "keys": ["ctrl+alt+r"], "command": "repl_transfer_current", "args": {"scope": "lines"}},
{ "keys": ["ctrl+alt+r", "r"], "command": "repl_transfer_current", "args": {"scope": "lines", "action":"view_write"}},

// Executes a block (e.g., a custom function) of text in REPL terminal, latter only displays code and does not execute
{ "keys": ["ctrl+shift+alt+r"], "command": "repl_transfer_current", "args": {"scope": "block"}},
{ "keys": ["ctrl+shift+alt+r", "r"], "command": "repl_transfer_current", "args": {"scope": "block", "action":"view_write"}}

]

What am I doing wrong?

  • 2
    Open the console (ctrl+~) and enter sublime.log_commands(True). Then tell us what the console says after entering the key binding. – d_rail Jul 28 '13 at 22:52
  • Many thanks @d_rail. Interestingly, I can't even call the console using ctrl+~ (the window menu says the shortcut is ctrl+` ; this doesn't work either). In any event, the console reports nothing when I press ctrl+shift+R with the sublime.log_commands(True) activated. Other common shortcuts, like ctrl+a, ctrl+c etc work and are reported in the console. – CaptainProg Jul 29 '13 at 11:55
  • Okay, here's the weird thing; if I press ctrl+shift+CapsLock+R, it works... – CaptainProg Jul 29 '13 at 14:27
  • Sorry to give you wrong info, the backtick is right. Sounds like the keybinding is not set. But, I don't see anything wrong with the settings listed. I would start with the default keybindings from here: github.com/wuub/SublimeREPL/blob/master/… (or the right one for your OS). And make sure that works. Then change one key at a time to see what's messing it up. – d_rail Jul 29 '13 at 20:12
  • Has a solution been found for this issue yet? – music2myear Mar 15 '17 at 19:46
0

This has a simple solution. There is an error in the configuration file, one simply needs to remove the shift+ctrl+r,r line:

[
// Modified Sublime-REPL keybindings for an "R-friendly" set of shortcuts.
// For more information, see http://tomschenkjr.net/2012/05/17/using-sublime-text-2-for-r/

// Executes a selection of text in REPL, latter only displays code and does not execute
{ "keys": ["ctrl+shift+r"], "command": "repl_transfer_current", "args": {"scope": "selection"}},

// Executes the entire file (build) in REPL, latter only displays code and does not execute
{ "keys": ["ctrl + f7"], "command": "repl_transfer_current", "args": {"scope": "file"}},


// Executes line(s) of text in REPL terminal, latter only displays code and does not execute
{ "keys": ["ctrl+alt+r"], "command": "repl_transfer_current", "args": {"scope": "lines"}},


// Executes a block (e.g., a custom function) of text in REPL terminal, latter only displays code and does not execute
{ "keys": ["ctrl+shift+alt+r"], "command": "repl_transfer_current", "args": {"scope": "block"}},


]
0

Thanks to the following comment from OP:

Okay, here's the weird thing; if I press ctrl+shift+CapsLock+R, it works...

I can guess that ["ctrl+shift+r"] waits for a lowercase r, however, when you've pressed shift (which is a part of the shortcut key combination), it reads an uppercase R.

When OP has turned his CapsLock on, pressing r would have normally outputted R, but while SHIFT key is pressed, it reads lowercase r.

This probably happens because Sublime tries to read the exact same character, rather than the key code of the pressed button.

And thus, the solution should be using the opposite case letter when in a key combination including SHIFT (using R instead of r in this case):

// Executes a selection of text in REPL, latter only displays code and does not execute
{ "keys": ["ctrl+shift+R"], "command": "repl_transfer_current", "args": {"scope": "selection"}},
{ "keys": ["ctrl+shift+R", "r"], "command": "repl_transfer_current", "args": {"scope": "selection", "action":"view_write"}},

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.