Reformat a code fragment in a file In the editor, select a code fragment you want to reformat. From the main menu, select Code | Reformat Code or press Ctrl+Alt+L . note. If you don't select a code fragment, PyCharm will reformat the whole file.