How to Set-Up Black to Automatically Reformat Your Code in Visual Studio Code

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 พ.ย. 2024
  • In this video, I will guide you through the process of installing and setting up Black to automatically reformat your Python code inside Visual Studio Code. Black is a powerful and popular code formatter that will help you maintain consistent style and formatting in your codebase. I will show you how to install Black, set it up in Visual Studio Code, and configure it to work automatically on file save.
    Keywords: Black, Python code formatter, Visual Studio Code, automatic code formatting, code consistency, PEP 8, Python development, development tools.
    Hashtags: #Black #Python #VisualStudioCode #CodeFormatting #PEP8 #DevelopmentTools #CodingTips #Productivity
    ⚠️ Join my channel to get access to perks: / @federicotartarini
    🙏 Support my channel on Patreon at / federicotartarini
    ☕ Support my channel by buying me a coffee - www.buymeacoff...
    ✅ Let's connect:
    🌍 My website - federicotartar...
    💻 GitHub - github.com/Fed...
    Twitter - / federicotartar1
    LinkedIn - / federico-tartarini
    🎥 Content of this video:
    00:00 - What you will learn

ความคิดเห็น • 19

  • @eliesfeir4511
    @eliesfeir4511 ปีที่แล้ว +11

    Hi , I can’t see « python formatting provider » what could be the reason ?

    • @ramanjaneyuluv479
      @ramanjaneyuluv479 ปีที่แล้ว +1

      Same here

    • @Fluttertrends
      @Fluttertrends ปีที่แล้ว +4

      Maybe you just added the VS Code extension if so try to check the box format on save searching "format on save" -> Settings -> Editor: format on save and in your settings.json add: "[python]": {
      "editor.defaultFormatter": "ms-python.black-formatter"
      }
      To find the settings.json search for setting. in the Settings search box

    • @RemiGft
      @RemiGft ปีที่แล้ว

      @@Fluttertrends Thanks a lot! I managed to activate "black" by checking "format on save" and when trying to save a Python file, VS Code asked me if I wanted to use "Black" to format the text by default.

  • @Hex0202
    @Hex0202 2 หลายเดือนก่อน

    I'm a complete begginer to python,took me hours to look for the correct formatter settings but your video made it so simple lol thank you very much ! (also liked the var example at the end) help me verify its working

    • @FedericoTartarini
      @FedericoTartarini  2 หลายเดือนก่อน

      Glad it helped! Thank you for letting me know

  • @BadBoyMT07
    @BadBoyMT07 8 หลายเดือนก่อน +5

    I have no 'Python formatting provider' option

    • @YoungHumanClub
      @YoungHumanClub 8 หลายเดือนก่อน

      same here

    • @FedericoTartarini
      @FedericoTartarini  8 หลายเดือนก่อน

      You can follow this guide learn.microsoft.com/en-us/visualstudio/python/formatting-python-code?view=vs-2022

    • @ApexWalrus
      @ApexWalrus 7 หลายเดือนก่อน +2

      That is unfortunately for Visual Studio, not Visual Studio Code

  • @davidfilestra8826
    @davidfilestra8826 ปีที่แล้ว +1

    Thank you for video! Formatting makes the code so beautiful and easily readable but I don't understand why Format On Type doesn't work, have encountered this issue?

    • @FedericoTartarini
      @FedericoTartarini  ปีที่แล้ว

      No I have not encountered it but i manly use pycharm. I do not use vscode much.

  • @morgana6598
    @morgana6598 ปีที่แล้ว +1

    Great Video, thank you so much :)

  • @yanir.tzabary
    @yanir.tzabary 12 วันที่ผ่านมา

    i dont have it on windows

  • @SushilKoirala-p3f
    @SushilKoirala-p3f ปีที่แล้ว

    can I use single quotes with black

    • @FedericoTartarini
      @FedericoTartarini  ปีที่แล้ว

      Black is quite opinionated so I am not sure you can change that. Look at their official documentation

  • @costcut
    @costcut ปีที่แล้ว

    Great!