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 it
If 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
In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. Select a language for which you want to configure the indentation. From the options on the right, on the Tabs and Indents, select the Use tab character for the editor to use tabs when you press Tab , indent, or reformat code.
Highlight/ select the lines you want indented, then press TAB as often as needed until they reach the proper indent level. You can remove spaces with SHIFT TAB . You can also use CTRL+ALT+I to auto-indent the selection.
The dialog appears when you press Ctrl+Alt+Shift+L in the editor of the current file. If you choose Code | Reformat Code from the main menu or press Ctrl+Alt+L , PyCharm tries to reformat the source code of the specified scope automatically.
ctrl + shift + A => open pop window to select options, select to spaces to convert all tabs as space, or to tab to convert all spaces as tab.
That action is called Reformat code
. You can find it in Code
menu, somewhere in the middle, or use the hotkey CTRL + Shift + L
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.
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