Skip to content

Instantly share code, notes, and snippets.

@flacle
Last active August 17, 2019 00:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flacle/28a8880d97b22efc12219b9e67d27c72 to your computer and use it in GitHub Desktop.
Save flacle/28a8880d97b22efc12219b9e67d27c72 to your computer and use it in GitHub Desktop.
Quick and Dirty Python 2.7 in Sublime Text 3
[
{"keys": ["shift+ctrl+alt+b"], "command": "repl_open",
"caption": "Python2 - RUN current file",
"id": "repl_python2_run",
"mnemonic": "R",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["/Users/your-name-here/anaconda/envs/python2/bin/python", "-u", "$file_basename"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python2"
}
}
]
@flacle
Copy link
Author

flacle commented Oct 17, 2017

You can copy and paste this Gist when you want to easily add a keyboard shortcut to execute scripts in a different version of Python with the package SublimeREPL. In this case, Python 2.7. Here I'm using Anaconda with a different environment for hosting Python 2.7. I also didn't see the need to edit the configuration of SublimeREPL to add a custom menu item for Python 2.7 in the user interface.

You can paste this Gist in Sublime -> Preferences -> Key Bindings -> Default (OSX).sublime-keymap -- User. Change your-name-here to your actual account name on the OS.

Note: Key bindings do not work when removing "encoding": "utf8" from the arguments list. Copy & paste as is for a first try

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