- package controll install SublimeREPL
- add python 3 build system Tools/Build System/New (optional)
{
"cmd": ["python3", "-i", "-u", "$file"],
"file_regex": "^[ ]File \"(...?)\", line ([0-9]*)",
"selector": "source.python"
}
This will save the file to Users/pkomsit/Library/Application Support/Sublime Text 3/Packages/User/Python3.sublime-build Try with Command+B with this code
import sys
print (sys.version)- add Python3 to SublimeREPL menu /Users/pkomsit/Library/Application Support/Sublime Text 3/Packages/SublimeREPL/config/Python/Main.sublime-menu
{
"caption": "Python",
"id": "Python",
"children":[
{"command": "repl_open",
"caption": "Python3",
"id": "repl_python3",
"mnemonic": "p",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python3", "-i", "-u"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
]
}
- custom settings
Preferences/Package Settings/SublimeREPL/Settings - User
{
// Where to look for python virtualenvs
"python_virtualenv_paths": [
"~/.virtualenvs", // virtualenvwrapper
"~/.venv" // venv.bash https://github.com/wuub/venv
],
// If set to true, SublimeREPL will try to append evaluated code to repl
// output before evaluation (e.g. Ctrl+, f)
"show_transferred_text": true,
// If set to true repl view (tab) that receives text for evaluation will
// be brought to front after text transfer. Note: This will not fire if repl view
// is in the same tab group as the view from which the code is sent.
"focus_view_on_transfer": false
}
Preferences/Key Bindings Default (OSX).sublime-keymap -- User
// custom SublimeREPL
{ "keys": ["super+shift+enter"], "command": "repl_transfer_current", "args": {"scope": "selection"}, "context": [{"key": "selector", "operator": "equal", "operand": "source.python"}]},
{ "keys": ["super+enter"], "command": "repl_transfer_current", "args": {"scope": "lines"}, "context": [{"key": "selector", "operator": "equal", "operand": "source.python"}]}
- more example
import urllib.request
fp = urllib.request.urlopen("http://www.python.org")
mybytes = fp.read()
mystr = mybytes.decode("utf8")
fp.close()
print(mystr)
See step 4. hit super+r to send r code to sublimeREPL R session