Optimize Your Python Workflow with This VSCode Configuration

Enrique Lazo Bello
3 min readNov 20, 2023

--

In my previous Medium post, “The Best VSCode Extensions for Python Programmers,” I explored a series of extension packages ideal for different levels of Python experience. Today, I want to share a settings.json configuration that complements these extensions, further optimizing your development environment in Visual Studio Code.

The settings.json file in Visual Studio Code is a powerful ally in customizing your development experience. Below, I present my current configuration, focusing on code efficiency and clarity, space and line management, and optimizing the use of the previously mentioned extensions.

  1. Configuration Fundamentals
  • Insert New Line at End of File: files.insertFinalNewline: true helps maintain consistency in code files and is a good practice in many programming languages.
  • Trim Spaces and New Lines: The settings files.trimFinalNewlines and files.trimTrailingWhitespace ensure a clean code free of unnecessary spaces at the end of lines or files.

2. Analysis and Formatting Tools

  • Configuring Pylint, Flake8, Black, autopep8, iSort, and Bandit: Discuss how each of these tools enhances code quality and how they are configured in settings.json to suit your specific needs (e.g., maximum line length, additional arguments, etc.).

3. Environments and Docker

  • Python Environment and Docker Configuration: Detail how python.defaultInterpreterPath and [dockercompose] help manage development environments and work with Docker.

4. Coding and Documentation Improvements

  • Indentation, Spaces, and Tab Sizes: Explore specific configurations for Python and Docker Compose that improve code readability and consistency.
  • File Exclusion and Search: Show how files.exclude and search.exclude facilitate project navigation by excluding unnecessary files and directories.

5. Interface and User Experience

  • Icons, Themes, and Explorer Visualization: Describe how the material-icon-theme and explorer.compactFolders settings enhance the visual experience in VSCode.

6. Git and GitLens

  • Advanced Git Integration: Comment on specific configurations for Git and GitLens that enable a more efficient workflow with version control.

7. Additional Settings

  • General Settings: Includes tips on additional settings such as editor.codeActionsOnSave, breadcrumbs.enabled, css.validate, etc., and how these improve the overall development experience.

Usage Tips

  • Be sure to adjust the paths of executables (like Pylint, Flake8, etc.) based on the location of your virtual environment or local installation.
  • Customize the formatting values and code styles according to your team’s standards or your personal preferences.

I’ve created a gist on GitHub with this configuration for different operating systems. You can find two versions: one for Unix users (Linux and Mac) and another for Windows users. Remember to rename the file to settings.json and place it in your .vscode folder before using it. Link to the gist: Boost Your Python Productivity with VSCode

Conclusion: With this guide, I hope you can configure your VSCode environment to perfectly suit your needs as a Python developer. By customizing these settings, you not only improve your efficiency but also your comfort and enjoyment while coding. Combining a well-chosen set of extensions with a carefully adjusted settings.json configuration can radically transform your Python development experience.

Happy Coding!

--

--

Enrique Lazo Bello

Software engineer and passionate gamer. Part of TeamCore. Lover of innovation. When I'm not working, I enjoy cooking and volunteering.