So when writing C/C++, I get to use the wonderful Clangformat tool, allowing me to write a loooong line and hit a keyboard shortcut to easily and elegantly format my line according to a sane style guide.
Is there an equivalent tool for python? Bonus points if it has a vim plugin.
autopep8 automatically formats Python code to conform to the PEP 8 style guide. It uses the pycodestyle utility to determine what parts of the code needs to be formatted. autopep8 is capable of fixing most of the formatting issues that can be reported by pycodestyle.
Prettier does not work with Python And don't forget to install and select the actual formatter that you want (just like in the official docs).
autopep8:
A tool that automatically formats Python code to conform to the PEP 8 style guide
To use:
pip install --upgrade autopep8
autopep8 --in-place --aggressive --aggressive <filename>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With