Ask coding questions

← Back to all posts
How to reformat and indent Python code
PaoloAmoroso (129)

In a Python REPL, suppose I edit some code in a file and break the canonical indentation. Is there an editor command to reformat and indent the code? I've the command palette but haven't found anything relevant.

Answered by malvoliothegood (432) [earned 5 cycles]
View Answer
malvoliothegood (432)

It can be tricky. You could try copying and pasting your code into an online formatter. E.g.

PaoloAmoroso (129)

@malvoliothegood So it looks like doesn't provide a reformat option. Thanks anyway.