2012-09-06 24 views
0

我想创建一个用于打开SublimeREPL的键绑定:在ST2中的Ruby窗口,但不知道是否可以为非基本命令创建快捷方式。可以SublimeText2键绑定映射到包命令,如“SublimeREPL:Ruby”?

我搜索了各种http://sublimetext.info/docs/en/reference/key_bindings.html并搜索了我的小心脏,但找不到任何有关为外部软件包创建密钥绑定的信息。

第二个想法(我是1y/o dev) - 我决定浏览包文件。我发现这在/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也许?

回答

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" 
    } 
},