I was following this beginner tutorial. I'd like to use a formatter to adjust indentation as he did. I tried to do the same things he did but it doesn't work.
How can achieve the same result?
I was following this beginner tutorial. I'd like to use a formatter to adjust indentation as he did. I tried to do the same things he did but it doesn't work.
How can achieve the same result?
There are 2 ways to go about it.
This extension is required as an addition to main Python extension as that by default doesn't handle whitespaces for some reason. It's pretty much the most basic support.
Then you have options for more advanced autoformatting like:
They're slower as they do much more, but if you want to efficiently and understandably program in Python, you'll have to get familiar with one at some point. Ruff is more recommended nowadays as it has more capabilities and it's written in Rust, so it's faster.
You can also run both Python Indent and autoformatter on file save, if you don't want to autoformat too frequently, which I'd definitely recommend as the way to go.
Python Indent
extension partially cover the behavior shown in the video but (e.g.) doesn't fix the indent for line04
variable. I tried both Ruff
and Black
but nothing's changed when I try to format the document.
line04
been indented? I'm using a brand new VSCode profile.