Collapse or folding code cell in Jupyter notebook
Hi,
I know there is a collapse or folding function when I work in normal editor with .py in Pycharm.
However, it seems this function is not available in Jupyter notebook in Pycharm.
Is there any way that I can fold or collapse code in Jupyter notebook?
Please sign in to leave a comment.
Hi,
Yes, you can fold/unfold regions of your code in Jupyter cells the same way as it works in .py files. If you're talking about folding an entire cell, there's no feature for that, but you can use "fold selection" functionality to select and fold code in the cell.
If you mean some specific folding that doesn't work, please provide more information.
any update on the collapsible feature?
The headers in Markdown cells can be collapsed and are visible in project structure. In code cells, you can create custom fold regions -- https://www.jetbrains.com/help/pycharm/working-with-source-code.html#expand-or-collapse-code-elements
If that's not what you mean, could you please provide more specifics?
I can't find that in Pycharm's notebooks (jupyter) either. The only collapsable things sem to be functions, string literals and maybe something more but you can't decide what should be collapsable and the predetermined ones are inside a code cell. I'd like to collapse an entire section behind a tittle (an h1 or any level markdown tittle); that is much more useful in notebooks.
I can do that in Collab at least, and I think it could be done at some point in Jupyter notebooks. I went to Collab just because of that though. I do see convenient to use notebooks inside Pycharm, but this is a big productivity deal...
Any way you (Jetbrains) implement that anytime soon?
Best!
Maybe if the outline (Structure panel) could directly move items, like Collab does, it wouldnt be super necessary the previous collapse - although it'd still help to just visualize the important things in a glance