Using Visual Studio Code as a lightweight Python IDE

Visual Studio Code is an extensible and customizable text editor from Microsoft that provides a very minimal layout with additional tooling such as an excellent built-in terminal.

Requirements

Any IDE should ease your development experience by providing the following:

  • It should provide excellent, configurable syntax colorization.
  • It should allow for robust tab completion.
  • It should offer the ability to jump to the definition of symbols in other files.
  • It should perform automatic code linting to help avoid silly mistakes.
  • It should be able to interact with a Python interpreter such that when debugging, the editor will follow along with the debugger.

Visual Studio Code requires that you perform some setup out of the box (see below for details).

Which Version?

There’s just the latest version available to download.

This ensures that all recent bug fixes and updates have been made.

Visual Studio Code runs on Macs, Windows, and Linux flavors like Ubuntu, Debian, Red Hat, etc.

Also, Visual Studio Code performs updates on itself, so there’s no need to download newer versions of the app… you should already have it.

Installation

Check out this solid video that will walk you through the process of setting up Visual Studio Code for Python in detail.

Go to the Visual Studio Code website.

Scroll down to the bottom of the page and you’ll see links for installers to all the major OS platforms.

Download your flavor and run the installer.

Basic Settings

Visual Studio Code can be used out of the box with no setup as a text editor. It automatically recognizes file types and helpfully highlights text accordingly. To use in this manner, write your Python files in Visual Studio Code, then run them in your Python command prompt or Visual Studio Code’s own built in terminal: Ctrl + ` (control-backtick)

Extending the Editor

After you’ve install Visual Studio Code, there are many ways to extend it for working with Python.

The video linked above goes into this much deeper.

There is also a great tutorial for setting up Python here.

If you’re on a Mac, be sure to set up your path for easy integration with the terminal.

I also recommend setting up Visual Studio Code as your default Git editor.