Search code examples
sublimetext3sublimetextread-eval-print-loopsublimerepl

Starting SublimeREPL with hotkey


How to add a hotkey for starting SublimeREPL for Python from SublimeREPL Package. You can start it from Command Palette by typing it, but I would like to assign it to key, lets say to f2.

This is what I have so far:

{ "keys": ["f2"], "command": "repl_open" ,"cmd": ["python", "-i", "-u"], 
"cwd": "$file_path", "encoding": "utf8", "extend_env": {"PYTHONIOENCODING": "utf-8"},
 "external_id": "python", "syntax": "Packages/Python/Python.tmLanguage", "type": "subprocess"} ,

But in console I can see this error:

TypeError: run() missing 2 required positional arguments: 'encoding' and 'type'

Solution

  • The arguments for the repl_open command need to be in an args dict:

        { 
            "keys": ["f2"],
            "command": "repl_open" ,
            "args": { 
                "cmd": ["python", "-i", "-u"], 
                "cwd": "$file_path", 
                "encoding": "utf8", 
                "extend_env": {"PYTHONIOENCODING": "utf-8"},
                "external_id": "python", 
                "syntax": "Packages/Python/Python.sublime-syntax", 
                "type": "subprocess"
            }
        },
    

    I also changed the name of the syntax to reflect its new name.