Skip to content

Instantly share code, notes, and snippets.

@komsit37
Last active November 11, 2021 10:49
Show Gist options
  • Select an option

  • Save komsit37/755c08068042168eb179ff9f290dae75 to your computer and use it in GitHub Desktop.

Select an option

Save komsit37/755c08068042168eb179ff9f290dae75 to your computer and use it in GitHub Desktop.

Using with SublimeREPL

  1. package controll install SublimeREPL
  2. 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)
  1. 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"}
      }
    }
  ]
}
  1. 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"}]}
  1. more example
import urllib.request

fp = urllib.request.urlopen("http://www.python.org")
mybytes = fp.read()

mystr = mybytes.decode("utf8")
fp.close()

print(mystr)
@komsit37

Copy link
Copy Markdown
Author

See step 4. hit super+r to send r code to sublimeREPL R session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment