Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm indentation spaces

Tags:

pycharm

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.

like image 860
user3307629 Avatar asked Feb 17 '14 14:02

user3307629


People also ask

How do I fix spacing in PyCharm?

While in the editor, select the necessary code fragment and press Ctrl+Alt+I . If you need to adjust indentation settings, in the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. On the appropriate language page, on the Tabs and Indents tab, specify the appropriate indents options and click OK.

How do you set a tab to 4 spaces in PyCharm?

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.

Does Python only accept 4 spaces indentation?

Python doesn't care, as long as you're consistent. So if you start using four spaces for your indent, you always need to use four spaces. For example, in this snippet of code, we can see that the first indent has four spaces, but the second indent has only two. And you can see that the code doesn't line up.

How do I show spaces in PyCharm?

You can select the following options: Leading: select this checkbox to add whitespaces before your code line. Inner: select this checkbox to display whitespaces inside the line of your code. Trailing: select this checkbox to display whitespaces after the code line.


1 Answers

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.

like image 110
Ilia Kopylov Avatar answered Oct 19 '22 04:10

Ilia Kopylov