Python in Visual Studio Code – February 2022 Release

Luciana Abud

We are pleased to announce that the February 2022 release of the Python Extension for Visual Studio Code is now available. This release includes:

  • Smart Selection
  • Folding support
  • Improvements to the Python interpreters list
  • Improvements when using Anaconda

If you’re interested, you can check the list of improvements in our changelog.

Smart Selection

Selecting Python code using the keyboard takes fewer key presses now thanks to Smart Selection via Pylance. This was a highly requested feature, and it takes into account your code structure and heuristics to define the selection range. You can expand your code selection with Shift + Alt + Right Arrow or ⇧ + ⌥ + Right Arrow, and shrink it with Shift + Alt + Left Arrow or ⇧ + ⌥ + Left Arrow.

Expanding and shrinking code selection with keyboard short keys for smart selection. Theme: Monokai – High Contrast

Folding support

We’ve also made improvements to folding support via Pylance. Previously, the folding regions were defined just by indentation, which was not ideal for some cases, for example, with multi-line strings as pointed out in our issue tracker. Now folding regions take into account semantic information appropriately (this includes #region comments).

You can fold regions of source code using the folding icons on the gutter between line numbers and line start. Move the mouse over the gutter and click to fold and unfold regions. Use Shift + Click or ⇧ + Click on the folding icon to fold or unfold the region and all regions inside.

Folding and expanding sections of code in the editor Theme: Horizon Extended

Improvements to the Python interpreters list

Similarly to how kernels are display in the Jupyter extension, the Python extension’s interpreters list now displays Python interpreters grouped by type to make it easier to identify them:

List of interpreters grouped by type: workspace, venv, conda, pyenv and global.

Improvements when using Anaconda

This release includes several improvements to the experience when using Anaconda environments. Previously, there would be issues when debugging files and running tools using conda environments unless VS Code was initiated in an activated conda environment. To resolve several of these issues (#5559, #11205, #11638), the Python extension is using “conda run” to execute files and tools.

There are known issues when there are special characters in file paths, or when using custom command lines arguments in VS Code (although the Anaconda team is already working on fixing it). If you experience any of these issues, we recommend you check to see if conda has been released with a fix, otherwise start VS Code (“code .” command) from an activated conda environment from an external terminal.

Other Changes and Enhancements

We have also added small enhancements and fixed issues requested by users that should improve your experience working with Python in Visual Studio Code. Some notable changes include:

  • Improve select folder quickpick UI in multiroot workspaces. (#18256)
  • Drop support for Python 3.6 (as it reached end-of-life in December). (#18272)

We would also like to extend special thanks to this month’s contributors:

Try out these new improvements by downloading the Python extension from the Marketplace, or install it directly from the extensions view in Visual Studio Code (Ctrl + Shift + X or ⌘ + ⇧ + X). You can learn more about Python support in Visual Studio Code in the documentation. If you run into any problems or have suggestions, please file an issue on the Python VS Code GitHub page.

1 comment

Discussion is closed. Login to edit/delete existing comments.

  • Faheem Ahmad 0

    Why does the VS code team always writes about Java and Python while note exactly telling what has changed and what has improved overall I mean if you want to see the change now and you open the app and try to see it hints you to the GitHub repository where it is impossible for beginners and even moderate users to understand what has changed and what has improved overall please also do better bigger and simpler blog posts for new updates in VS code as well And in this page too

Feedback usabilla icon