If no results come up, make sure you have the Python extension installed. If the key sequence you press is already assigned to something else, VS Code will warn you with a link to see which commands are mapped to this keybinding.Īs an example, type python create terminal in the search box at the top. To assign a keybinding to a command that has no binding, double-click on it. To override an existing binding, right-click on the existing action and click Change Keybinding.
In this editor, you can see a list of all the existing shortcuts along with their details: Open the Keyboard Shortcuts editor by going to File → Preferences → Keyboard Shortcuts or Code → Preferences → Keyboard Shortcuts on macOS: These don’t come with shortcuts mapped by default, but you can configure them using VS Code’s Keyboard Shortcuts editor.
If you want to learn these default shortcuts, print out the PDF for Windows, macOS, or Linux and pin it next to your monitor.Īs a Python developer, a lot of the commands you’ll use in Visual Studio Code are provided from extensions, similar to the Python extension that you already installed. You can map all activities in VS Code, whether they’re built-in or provided via extensions, to a keyboard shortcut.Ī small subset of built-in commands is already mapped in Keyboard Shortcuts. If you’re just getting started with VS Code, you might want to check out Jon Fincher’s tutorial on Python development in Visual Studio Code before continuing with this one.įor almost everything that you do in VS Code, you can do it directly from the keyboard. If you haven’t already installed Visual Studio Code or the Python extension, you’ll need both for this tutorial.
In this tutorial, you’re going to look at how to get the most out of VS Code for Python development.ĭuring this tutorial, you’ll learn how you can configure, extend, and optimize VS Code for a more effective and productive Python development environment.
You can use VS Code as a lightweight code editor to make quick changes, or you can configure it as an integrated development environment (IDE) through the use of third-party extensions. Those steps are essentially "run a command on save", and it turns out someone has already written an extension! emeraldwalk/vscode-runonsave reads Visual Studio Code settings, matches files on a regular expression, and then runs a user-supplied command.Visual Studio Code, or VS Code for short, is a free and open source code editor by Microsoft. After about 10 minutes into the exercise, I realized that this plugin was going to be quite dumb: I started down the path of writing my own Visual Studio Code plugin to run google-java-format as a formatter. I also stumbled across Dev-Snippets/vscode-google-java-format-provider, which seemed promising, but I was unable to get it to register as a formatter (and I am not the only one).
Worse, it modified things like license headers, rendering them invalid. While this does change the default format of the code, in my testing it did not match the output of running google-java-format directly from the command line. This seemed like a great fit, since I am already using RedHat's Java Language Support. This will instruct the editor to use the "GoogleStyle" when formatting code instead of the built-in style.