Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make VS Code format my Python code?

I have following Python code:

check_files(original_file = original_file_name, 
                   used_file = used_file_name, 
                   unused_file = unused_file_name)

I want to make it instead to look like:

check_files(original_file = original_file_name, 
            used_file = used_file_name, 
            unused_file = unused_file_name)

Also I want to correct formatting not only for function calls but also that way dictionary key/value pairs and etc.

For Example, in RStudio, if I select the code and press CTRL + I RStudio will correct formating as I have described above. Is there any similar way to correct formating in VSCode?

like image 238
vasili111 Avatar asked Apr 03 '26 04:04

vasili111


1 Answers

Or simply install Black Formatter from VSC extension menu:

https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter

enter image description here

:)

like image 102
Davor Avatar answered Apr 08 '26 07:04

Davor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!