Sublime文本键盘快捷键绑定不起作用


11

按照此处的说明,我已经安装了SublimeText的新安装以便与R一起使用。我没有安装其他SublimeText插件。使用上方链接中的说明设置的键盘快捷键不起作用。我已经按照教程中的说明设置了用户密钥绑定文件。

“默认”键绑定文件中没有冲突的键绑定。

尽管如此,我可以通过单击菜单在REPL中执行我的R代码:

工具> SublimeREPL> REPL中的评估>选择(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"}}

]

我究竟做错了什么?


2
打开控制台(ctrl +〜)并输入sublime.log_commands(True)。输入密钥绑定后,然后告诉我们控制台怎么说。
d_rail

非常感谢@d_rail。有趣的是,我什至无法使用ctrl +〜调用控制台(窗口菜单显示快捷方式为ctrl +`;这也不起作用)。无论如何,当我在sublime.log_commands(True)激活状态下按ctrl + shift + R时,控制台不会报告任何内容。其他常见的快捷方式(如ctrl + a,ctrl + c等)也可以在控制台中报告。
CaptainProg

好吧,这很奇怪。如果我按ctrl + shift + CapsLock + R,则可以...
CaptainProg 2013年

抱歉给您错误的信息,反驳是对的。听起来好像没有设置键盘绑定。但是,我没有看到列出的设置有任何问题。我将从此处的默认键绑定开始:github.com/wuub/SublimeREPL/blob/master/…(或适合您的操作系统的键绑定)。并确保可行。然后一次更改一个键,看看有什么麻烦。
d_rail

是否已找到解决此问题的方法?
music2myear

Answers:


0

这有一个简单的解决方案。配置文件中有错误,只需删除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"}},


]

0

感谢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"}},
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.