Sublime text 3.x is one of the light weight multi platform python editor,one good thing about this editor is that you can even keep a portable version for windows OS.
In this post, we are going to discuss python setup on windows OS
Prerequisite
You should have python installed on your machine, if not follow python on windows
Download
Install Packages
Sublime Text doesn’t come with a default setup for python auto suggestion, we need to install some packages to execute python.
To install package in Sublime text
Ctrl + Shift + P | Install Package | <name of package>
Let’s install following packages one by one
This helps in python auto completion or autosuggestion
Helps in python auto completion with added features, find more on Anaconda
This will enable right click context menu option “create python package” on project structure
You can activate this Color Scheme under Preferences | Color Sceheme…
You can activate this theme under Preferences | Themes…
Run command
To run or execute python on sublime text, key press Ctrl + b
File | new file and save as test.py
Let’s see in action
flag = True if flag: # print("True") print("me\"mine\"") print('false') word = "qavalidation" print(word + " Length - " + str(len(word)))
Key press Ctrl+b and see the output
me"mine" false qavalidation Length - 12
Customization
There are several theme and color-schemes available to install for sublime text 3.x, chose which one suits to your need,
Customise editor panel
Preferences | Settings | preferences.sublime.settings – user
"font_size": 12, "font_face": "Ubuntu mono"
and save
This will increase the font size of editor panel, to increase the sidebar font details, follow below steps
Customise sidebar
Step 1 : Tools | Command Pallete | Install Package
type PackageResourceViewer
and enter
Step 2 : Tools | Command Pallete
type prv open
and enter
Step 3 : Type Theme – [installed theme], select to edit
Search for //Sidebar entry and add below lines as needed
"font.size": 16, "font.face": "Ubuntu mono"
To view folder structure of current project
View | Side bar | Show Open Files
Link to specific python version
Create a new file
{ "cmd": ["C:\\python", "-u", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python", "shell": true }
Note : Under “cmd” – mention path of python installed, in my case it is c:\\python folder
Save the file with name “myPython.sublime-build” under …\Data\Packages\User [for portable version]
if installed, then under %AppData%\Roaming\Sublime Text 3\Packages\User
Keep “myPython” selected when you run the script, you can do this under Tools | Build System | myPython
If you have any interesting setup or tweaks for sublime text, please feel free to comment!!!