按照说明这里,我已设置了新安装的 SublimeText 以用于 R。我没有安装其他 SublimeText 插件。使用上面链接中的说明设置的键盘快捷键不起作用。我已按照教程中指定的方式设置了用户键绑定文件。
“默认”键绑定文件中没有冲突的键绑定。
尽管如此,我能通过点击菜单在 REPL 中执行我的 R 代码:
工具 > SublimeREPL > REPL 中的 Eval > 选择(Ctrl+ Shift+ R)
如果我真的按下Ctrl++快捷键,什么也不会发生Shift。R
这是我的用户密钥绑定文件的副本:
[
// 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"}}
]
我究竟做错了什么?
答案1
感谢OP的以下评论:
好吧,奇怪的是,如果我按下 ctrl+shift+CapsLock+R,它就可以起作用......
我可以猜测["ctrl+shift+r"]
等待小写r
但是,当您按下 shift (快捷键组合的一部分)时,它会读取大写的R
。
当 OP 打开 CapsLock 时,按下r
通常会输出R
,但SHIFT
按下 键时,它会读取小写的r
。
发生这种情况的原因可能是 Sublime 尝试读取完全相同的字符,而不是按下按钮的键码。
因此,解决方案应该是在组合键中使用相反的大小写字母,包括SHIFT
(在这种情况下使用R
而不是):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"}},
答案2
这有一个简单的解决方案。配置文件中有一个错误,只需删除 shift+ctrl+r,r 行:
[
// 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"}},
]