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
Hi , I can’t see « python formatting provider » what could be the reason ?
Same here
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
@@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.
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
Glad it helped! Thank you for letting me know
I have no 'Python formatting provider' option
same here
You can follow this guide learn.microsoft.com/en-us/visualstudio/python/formatting-python-code?view=vs-2022
That is unfortunately for Visual Studio, not Visual Studio Code
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?
No I have not encountered it but i manly use pycharm. I do not use vscode much.
Great Video, thank you so much :)
Glad you enjoyed it!
i dont have it on windows
can I use single quotes with black
Black is quite opinionated so I am not sure you can change that. Look at their official documentation
Great!
Thank you so much.