Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make pyCharm stop hiding (unfold) my Python imports?

Every time I open a Python file PyCharm will hide all imports and shows:

import ... 

within the editor.

I have to manually unfold it to see the imports. Where do I find the setting to undo auto-hiding of import statements?

like image 332
SmCaterpillar Avatar asked Aug 05 '14 09:08

SmCaterpillar


People also ask

Why does PyCharm GREY out imports?

The module easygui is imported and is used for nothing. So PyCharm tells you that the module is unused, not unsuccessfully imported. If you use the module in another piece of code, the grey line will disappear: import easygui easygui.

How do you fold codes in PyCharm?

To fold or unfold a code fragment, press Ctrl+NumPad - / Ctrl+NumPad + . PyCharm folds or unfolds the current code fragment, for example, a single method. To collapse or expand all code fragments, press Ctrl+Shift+NumPad - / Ctrl+Shift+NumPad + .

How do you fold code in Python?

It maps alt+1 to fold the first python indent level (class definitions and functions), alt+2 to fold the second level (class methods), and alt+0 to unfold everything. It makes sure it only folds one level and doesn't fold any of the nested sub levels. You can still use za to toggle folding for the current block.


1 Answers

As this question may be useful for people who also are not looking for the term "code folding", I'll make my comment an answer.

As extracted from IntelliJ IDE Web Help, but also worked on PyCharm CE 3.4.1:

  1. Open the IDE Settings (File > Settings, or Ctrl+Alt+S).
  2. Under the "Editor" node, click "General" and then "Code Folding". The "Code Folding" page is displayed.
  3. In the "Collapse by default list", select the check boxes to the left of the code constructs you want to be displayed collapsed. So here you can uncheck "Imports".
  4. Apply changes.

The image below shows what it looks like:

enter image description here

like image 65
Gustavo Meira Avatar answered Oct 11 '22 13:10

Gustavo Meira