Change the code style to use spaces instead of tabs:
Then select a folder you want to convert in the Project View and use Code
| Reformat Code.
This only converts the tabs without changing anything else:
Edit -> Convert Indents -> To Spaces
For selections, you can also convert the selection using the "To spaces" function. I usually just use it via the ctrl-shift-A then find "To Spaces" from there.
Open preferences, in macOS ⌘; or in Windows/Linux Ctrl + Alt + S.
Go to Editor -> Code Style -> Python, and if you want to follow PEP-8, choose Tab size: 4, Indent: 4, and Continuation indent: 8 as shown below:
Apply the changes, and click on OK.
Option 1: You can choose in the navigation bar: Edit -> Convert Indent -> To Spaces. (see image below)
Option 2: You can execute "To Spaces" action by running the Find Action shortcut: ⌘⇧A on macOS or ctrl⇧A on Windows/Linux. Then type "To Spaces", and run the action as shown in the image below.
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.
ctr+alt+shift+L -> reformat whole file :)
Just ot note: Pycharm's to spaces function only works on indent tabs at the beginning of a line, not interstitial tabs within a line of text. for example, when you are trying to format columns in monospaced text.
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