An Overview of Sublime Text 2 with Python

One of the key tools of each developer is a well-integrated developer environment (IDE). Python is a beautiful language with great support from a budding community of developers, who continue to create amazing libraries and extensions. Those are two reasons there are numerous IDEs for Python. They range from commercial ones, like Komodo and PyCharm, plugins for other IDEs, like PyDev for Eclipse, all the way through IDLE, which is lightweight and comes bundled with Python installation. However, some users prefer to use the text editor for almost all their needs, including developing. Sublime Text 2 is one of those text editors and here, I will show some of the peculiarities of using Sublime Text 2 with Python.

Why Go For Text Editors

In the beginning, there are always two arguments, one for using a text editor for coding, and one against. This is not the topic of this article, but it’s worth noting that both arguments make sense and depending on the usage and the proficiency of the user, one of them will be more suitable. For my needs, and generally the needs of developers who are working on relatively smaller-scale projects (especially projects containing only one file), text editors come in very handy. Some advantages they offer are that they:

  • are Lightweight
  • are Customizable
  • have Plugins
  • support Cross-platform development
  • support many languages

Introducing Sublime Text 2

Sublime Text 2 is one of the newer text editors. It is still being developed; thus, new features and bug fixes are coming out quite often. I personally use the builds from the dev channel, which has relatively frequent updates here: Sublime Text 2 is free for download and evaluation, and a license costs $59, but the free version is completely functional. Apart from a pop up that shows up once in a while, there aren’t many nuisances to the product especially considering that its functionality is not limited by any means.

Sublime has great and innovative features. It offers various themes, a lot of customization, plugin architecture (written in Python), it’s lightweight compared to full IDEs, available on all platforms and it’s constantly being developed. Some really clever things why I use it and why the Python community loves it are as follows:

  • multiple cursors
  • snippets
  • syntax highlighting
  • GIT support
  • full screen & distraction free mode
  • automatic builds

Sublime also offers an innovative console, which can be accessed with CTRL+SHIFT+P:

Introducing Sublime Text

It offers various options, like setting the current syntax, managing plugins, using snippets and so on. Package manager, which provides access to many plugins, including Python ones, can be accessed that way too.

Why Use Sublime Text 2?

Some of the key characteristics which make Sublime suitable for Python developments are listed below.

1. Code snippets (available from menu and from keyboard shortcuts)

They offer automatic selection when tabbing, which reduces time and errors needed to create some tedious parts of code.

Why Use Sublime Text

This snippet can be entered by pressing enter, or it is shown that in the file, if you type „for“ followed by tab, the snippet will be created automatically.

Why Use Sublime Text 2

On the screenshot above, “x” is selected, and upon tabbing the range values will be selected, so tab hopping is quick and focuses on the right places when using snippets.

2. Syntax highlighting and builds

It automatically offers syntax highlighting and builds, so upon creating a file, by using CTRL + B you can instantly see the output of the code in the console of the editor.
Syntax highlighting and builds

3. Python auto completion with the help of SublimeROPE plugin

SublimeROPE supports looking for declarations in other files too, which makes this very handy when dealing with larger projects.

Python auto completion with the help of SublimeROPE plugin

SublimeROPE also offers jumping to definitions, showing documentations and locating globals, so basic refactoring is also supported.

Python auto completion with the help of SublimeROPE plugin 1

4. Python interpreter  inside editor

SublimeREPL offers a Python interpreter (among other languages) that can be run inside Sublime Text 2. Combined with the split screen views, this becomes very handy.

Python interpreter  inside editor

5. Linters

Sublime 2 supports error detection programs/linters (like pyflakes), which can be superbly integrated with SublimeLinter plugin.


6. Conversion of indentation to spaces

This is a mandatory thing for each Python coder, as the spaces are preferred and sometimes when copying code, a mix up can happen, which is very bad for Python. Python Enhancement Proposals suggest that too, and sublime offers this in a neat interface with great and visible results, as shown on the screenshots below.

Conversion of indentation to spaces

Conversion of indentation to spaces 1

There is a clear difference between the spaces in line 2, which are shown as dots, and those in line 3, which represent tabs. With the “Convert Indentation to Spaces” feature, this can be resolved and Python won’t be confused.

There’s Always Room for Improvement

However, there are some things that could be improved compared to the full-fledged IDEs:

1. Debugging

This is a pain for most text editors, and although there are some things that can help, like PdbSublimeTextSupport 0.2 which integrate Sublime with the Python debugged, pdb,  IDEs like Eclipse offer far better debugging features.

2. Managing large projects can also be an issue, but project browser and SublimeRope offers autocompletion across various files in project, so this can be circumvented.


To sum up, Sublime Text 2 is a great editor which offers extraordinary customizing options. You can tailor it to your needs, use many of the available plugins and Python works great with Sublime. If you have some suggestions or great setups for Python development using Sublime Text 2, feel free to share them via comments.

Leave a Reply

Your email address will not be published. Required fields are marked *