Create a code section in PyCharm

Hey, 

I have a very quick question:

Is it possible to manually create code sections in python that i can collapse and expand?

In RStudio for example, you can create a section with this syntax:

`### mysection ---- `

It would be really helpful to have someting similar to this in PyCharm. In addition to collapsing of for loops or functions.

Cheers.

5 comments
Comment actions Permalink

Hello Andrey, I have the same question as the original writer, but unfortunately you did not answer it. Folding a region is not the same as being able to _permanently_ add section markers, which also help navigating in the Structure pane, for example.

0
Comment actions Permalink

Martin Winter Hi, 

I didn't mention it before, but you can surround multiple lines of code with a fold region comments. Please see https://www.jetbrains.com/help/pycharm/working-with-source-code.html#use-the-surround-with-action

0
Comment actions Permalink

Andrey Resler Thanks for your reply. This is a bit better, but still does not match what Rider does for C#: The region comments there also appear in the Structure pane, allowing for quick scanning of the file and even for collapsing of regions in the pane (like in an outline). This would help tremendously with larger files that have several groups of topically related methods.

0

Please sign in to leave a comment.