ChatGPT解决这个技术问题 Extra ChatGPT

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?

Thanks! And I kept searching for "hide imports", "unfold imports", did not know there was a general setting for "code folding" :-)

G
Gustavo Meira

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:

Open the IDE Settings (File > Settings, or Ctrl+Alt+S). Under the "Editor" node, click "General" and then "Code Folding". The "Code Folding" page is displayed. 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". Apply changes.

The image below shows what it looks like:

https://i.stack.imgur.com/ZJwzg.png


This is now Editor > General > Code Folding, rather than just Editor > Code Folding
Thanks, that feature was super annoying
... And "Collapse by default list" is now renamed to "Fold by default".
H
Hamish Downer

https://i.stack.imgur.com/VVdbi.png

Actually in pycharm 2016.1 it's Editor -> General -> Code Folding