How to use pycharm to auto indent the select area by the template of the coding style
Solution 1
That action is called Reformat code
. You can find it in Code
menu, somewhere in the middle, or use the hotkey CTRL + Shift + L
Solution 2
The latest version of PyCharm uses CTRL + SHIFT + ALT + L in both Linux and Windows. Then from the reformat dialog box, choose what reformatting option you want to perform.
Solution 3
CTRL + Shift + L will reformat your code.
Solution 4
If you happen to use/switch to Mac then the default is is cmd+alt+L
Solution 5
On Windows 10, keyboard shortcut is Ctrl+Alt+i
The option can be found in Code menu -> Auto-Indent Lines
python
Updated on March 17, 2021Comments
-
python over 3 years
Well, In eclipse, I can set the code-style template , when the code finish, I could indent it by the template. For example,
In the coding style template, I set the style is as following:
aDict = {1: 'a', 2: 'b'}
## that is each variable got a whitespace in front of itIf I write the code like this
aDict = {1:'a',2: 'b'}
How can I indent the code after I wrote it?
I tried the "code-Auto Indent Lines", which is binding to Hot-Key "Ctrl + Alt + I",but It seems doesn't work
-
Krachtwerk about 10 yearsOn Windows it's [Ctrl] + [Alt] + [L]
-
radtek over 8 yearsHow do you disable the
Auto-Indent Lines
when youReformat Code
? It seems to run every time now, where before I could set it as a separate in a dialog. -
Roel over 6 yearsit is ctrl + shift + alt + L
-
Magoo over 3 yearsIf you don't know the shortcut don't post