Reputation: 143
How can I change indentation in pycharm to only 2 spaces instead of 4? My team follows the pep8, but chose to use 2 spaces instead of four, and I can't find anywhere to change it.
Upvotes: 14
Views: 24707
Reputation: 12222
To add to the other answers:
You can also set the number of spaces in an .editorconfig
file with indent_size = <some integer>
.
I was working on a project for a company and having my Python files indented with two spaces instead of the 4 specified in my PyCharm settings, and it was because of this method of specifying the indentation.
Upvotes: 0
Reputation: 788
File -> Settings -> Editor -> Code Style -> Python (or "General" for all text files) -> Tabs and Indents (tab).
And there is a search tool in the top left corner of the settings window. You can use it to search any IDE setting.
Upvotes: 20
Reputation: 2933
Please follow the below steps to change the tab/indent size-
File -> Default Settings...
Editor -> Code Style -> Python/Other File Types
Below pics will help you more-
Upvotes: 2
Reputation: 3827
You can set "tab size" to 2 and "indent" to 2. in the File -> Settings -> Code Style -> Python -> Tabs and Indents (tab)
check "Use tab character" in the File -> Settings -> Code Style -> Python -> Tabs and Indents (tab).Now the error or warning message like PEP8: indentation contains tabs
will be removed. If the issue exist close the open files and reopen, or simply restart pycharm.
Upvotes: 3