Sublime Text Editor has been around since 2008 and has remained one of the most intuitive, free, and feature-packed code editors on the market. It is great for new and seasoned developers alike, with features like multi-tab select, git integration, key bindings, file patterns, and a native command-line interface to make your workflow more efficient.On top of this, visual customizability allows the developer to create, import, and edit Sublime’s interface themes and color schemes.
By default, you can use it for any programming language — but its Python support is considered one of the best. Why? Because it’s written in C++ and Python. You might even say that Sublime Text is the best code editor to understand Python because it is part Python.
But why, exactly, should you use Sublime Text for Python development?
Why use Sublime Text for Python development?
It only takes three words to sum up the awesomeness of Sublime Text for Python and they are speed, interface, and customization.
Speed
Sublime Text is super fast. Unlike other IDEs that may take a bit of time to boot up and maybe bombard you with a few welcome messages and multi-tabs of text about the editor each time you boot it up, Sublime Text just opens.
Not only that, it opens and leaves exactly where you left off — including unsaved changes and code that may have been lost with any other editor. In a way, it’s like you never left. So there’s no worry about low laptop battery or panic when Windows randomly forces you to restart mid-way through your work. You can close Sublime Text safely and know that everything will return to you intact and without any glitches.
Interface
Sublime Text’s interface is one of the cleanest interfaces for a code editor. With many IDEs, you’re bombarded with options galore, with side and bottom panels that often take up screen real-estate. Sublime Text’s beauty lies in its minimalist approach, showing only what is necessary, which gives you the space to focus on your code.
Opening up a new project won’t close your current project either. Instead, it opens up a completely new window for you to arrange as you wish on your screen. The separation can come in handy when you’re referencing multiple codebases.
Some IDEs and code editors only allow for one project at a time. Sublime Text preserves your open projects and keeps them separated from each other. You don’t need to worry about accidentally editing the wrong files when you’ve got more than a dozen files open.
Customization
Sublime Text comes with a core set of rich features such as key bindings, indentation preferences, spell checks, multi-select, and file patterns. The highlight for Sublime Text is the ability to extend the current functionality with a thing called Packages.
Packages can be anything. This includes plugins, syntax highlighting customization, menus, and code snippets. In a way, packages can be seen as extensions that are pluggable into Sublime to perform whatever task you want.
Keep up with software development’s evolving field
To remain relevant in the constantly changing landscape of software development, it is essential to stay up-to-date with the latest advancements and trends. Keeping abreast of new technologies and practices ensures that you are equipped with the knowledge and skills needed to succeed in this dynamic field. Learn more about how to utilize AI to optimize your software engineering in 2023.
How to set up Sublime Text for Python development
Step 1: Download Sublime Text and have Python set up on your computer
You can download Sublime Text at sublimetext.com. Once completed, run the .exe file to complete the installation process.
You also need to have Python set up on your computer. If you haven’t already done this, you can download Python from python.org. Select the version of your OS system and follow the installation instructions. If you’re on Windows, just run the .exe file and follow the wizard.
Step 2: Configuring Sublime Text for Python
Sublime Text comes pretty complete and ready for you to code out of the box. However, if you want to leverage Sublime Text for Python, you should install and configure the integrated terminal.
Without further ado, let’s get to installing and configuring the Integrated Terminal.
Go to ‘Command Palette’ located under ‘Tools’.
Type in ‘Install Package Control’ and select it from the drop-down that appears. This will install ‘Package Control’ on your Sublime Text editor.
If the install went correctly, you will get a pop-up message like this:
The next thing to do is install ‘Terminus’. To do this, start typing in ‘Package Control’ and select ‘Package Control: Install Package’ from the dropdown list that appears. (If your search bar disappears, just get back into it by navigating to Command Palette again).
This will give you a new dropdown list of available packages that you can install to enhance your Sublime experience.
Look for ‘terminus’ and select it.
This will download the package. Once completed, it will appear under ‘Preferences’ > ‘Package Settings’ > ‘Terminus’
You can open up Terminus by opening up ‘Command Palette’ again and typing in ‘Terminus’. Select ‘Terminus: Open Default Shell in Panel’. This will open up your command line.
Here is what it looks like:
The last thing to do is set the syntax to Python by opening up ‘Command Palette’ again and then typing in ‘Python’. Select on the ‘Set Syntax: Python’ option. This will ensure that your highlighting is based on Python syntax, making it easier to read your code.
Now all that’s left to do is run your first Python code. To do this, use your terminal as you would any Python project. In the example below, we have a simple ‘Hello world’ Python script and used Terminus to run it.
Top Sublime Text Packages for Python developers
Using Command Palette, you can install whatever packages you want to enhance your Python workflow. Here is a quick list of the top packages you need to get started.
1. Package Control
Package Control is your main hub for installing packages. You need to install this first before you can install anything. Once installed, you will have the option to select ‘Package Control: Install Package’. This will open up a list of available packages for Sublime Text.
From here you can install any of the dozens of packages available. Navigate to ‘Command Palette’ > type and select ‘Package Control: Install Package’ > search and select the package of your choice and have fun!
2. Tabnine for sublime
Tabnine is an intelligent, AI-driven code completion tool that can cut your coding time, reduce mistakes, and make best practice suggestions. It supports over 30 languages, with Python being one of them.
Once you’ve done that, you will see an ‘Installing package’ message at the bottom of your Sublime Text editor. Once completed, you can start using Tabnine right away.
3. requirementstxt
requirementstxt is a handy plugin that provides syntax highlighting, and easy version management for your requirements.txt files.
4. Anaconda
If you’ve played with requirementstxt and it’s not to your fancy, Anaconda is another good alternative. Anaconda turns your Sublime Text editor into a Python-ready IDE by including autocompletion, code linting, autopep8 formatting, McCabe complexity checker Vagrant and Docker support.
5. AutoPEP8
AutoPEP8 is a package that will automatically format your Python code to PEP 8 style guide for you. This means with your chosen key binding, you can quickly lint spaces to the correct standard.
6. SublimeLinter
Linting is an automated checking tool that checks for style and potential errors in your code. SublimeLinter is a staple linting tool in Sublime Text that is highly supported and frequently updated to ensure that the latest standards are met.
Wrapping it up
Overall, Sublime Text is one of the fastest and responsive free code editors available. When it comes to Python, you don’t need a large suite of packages to get started. Terminus is a handy package to have to give that IDE feel without the lag.
Coding Python in Sublime Text is a no-frills experience. The minimalistic interface makes it a distraction-free area. In addition to this, the large ecosystem of packages ensures that your every development need is met. All you have to do is install it via the ‘Command Palette’.
Tabnine
Tabnine is an intelligent, AI-driven code completion tool that can cut your coding time, reduce mistakes, and make best practice suggestions.
Get Started