0

我正在尝试创建用于在 ST2 中打开 SublimeREPL:Ruby 窗口的键绑定,但不确定是否可以为非基本命令创建快捷方式。

我搜索了http://sublimetext.info/docs/en/reference/key_bindings.html并用谷歌搜索了我的小心脏,但找不到任何关于为外国包创建键绑定的信息。

第二个想法(我是 1y/o 开发人员) - 我决定浏览包文件。我发现这个/Users/administrator/Library/Application Support/Sublime Text 2/Packages/SublimeREPL/config/Ruby

[
 {
    "id": "tools",
    "children":
    [{
        "caption": "SublimeREPL",
        "mnemonic": "r",
        "id": "SublimeREPL",
        "children":
        [
            {"command": "repl_open", 
             "caption": "Ruby",
             "id": "repl_ruby",
             "mnemonic": "r",
             "args": {
                "type": "subprocess",
                "external_id": "ruby",
                "encoding": "utf8",
                "cmd": {"windows": ["irb.bat", "--noreadline", "--inf-ruby-mode"],
                        "linux": ["irb", "--noreadline", "--inf-ruby-mode"],
                        "osx": ["irb", "--noreadline", "--inf-ruby-mode"]},
                "soft_quit": "\nexit\n",
                "cwd": "$file_path",
                "cmd_postfix": "\n", // postfix 
                "suppress_echo": true,
                "syntax": "Packages/Ruby/Ruby.tmLanguage"
                }
            }
        ]   
    }]
}
]

我创建了键绑定:{ "keys": ["super+i", "super+r", "super+b"], "command": "repl_open" }

但没有骰子。有任何想法吗?重启ST2可以吗?

4

1 回答 1

2

当您定义快捷键时,您应该向repl_open命令提供它在您提供的菜单项的声明中获得的参数。

尝试以下(未经测试,但与我在 REPL 中的另一个环境中的配置非常相似):

{ "keys": ["super+i", "super+r", "super+b"], "command": "repl_open", "args":
   {
        "type": "subprocess",
        "external_id": "ruby",
        "encoding": "utf8",
        "cmd": {"windows": ["irb.bat", "--noreadline", "--inf-ruby-mode"],
            "linux": ["irb", "--noreadline", "--inf-ruby-mode"],
            "osx": ["irb", "--noreadline", "--inf-ruby-mode"]},
        "soft_quit": "\nexit\n",
        "cwd": "$file_path",
        "cmd_postfix": "\n", // postfix 
        "suppress_echo": true,
        "syntax": "Packages/Ruby/Ruby.tmLanguage"
   }
}

一个更简单的选项(但配置较少)只是直接调用菜单项(同样,未经测试,但类似于我的配置):

{ "keys": ["super+i", "super+r", "super+b"],
  "command": "run_existing_window_command", "args":
    {
        "id": "repl_ruby",
        "file": "config/Ruby/Main.sublime-menu"
    }
},
于 2012-10-22T21:40:43.057 回答