question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make cells (# %%) collapsible python files

See original GitHub issue

Environment data

  • VS Code version: 1.33
  • Extension version (available under the Extensions sidebar): Current
  • OS and version: Win10 1703
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda 3.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): Conda
  • Relevant/affected Python packages and their versions: n/a

Expected behaviour

In a document with multiple cells, collapsing some of them improves usability.

Actual behaviour

It is not possible to collapse cells.

Some Details

I think defining #%% as (collapsible region start) shouldn’t be very hard (I can try to submit a PR in 1-2 weekends if you agree with the idea).

Some implementation details should be evaluated though:

  • Behavior of Shift+Enter in the cell above
  • What to display if a region is collapsed (#%% Comment ... would be the default I think)
  • Behavior of collapsed regions affected by Run below|above
  • Visibility of Run Cell | Run Above | Run Below

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:96
  • Comments:26 (9 by maintainers)

github_iconTop GitHub Comments

31reactions
rchiodocommented, Jun 1, 2020

Sorry but this isn’t on our radar at the moment. It’s waiting for more people to up vote it.

24reactions
richarddwangcommented, May 31, 2020

Is there anything new ? This should be set to important because I believe most of data science and ml guys write long jupyter notebook. And we are used to collapse those cells in Colab.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to organize Python code into collapsable / expandable ...
Turns out that the answer is very simple: Select the code, right click, do custom folding. enter image description here.
Read more >
Example: Collapsed Outline and Grouping - XlsxWriter
Example of how to use Python and XlsxWriter to generate Excel outlines and # grouping. # # These examples focus mainly on collapsed...
Read more >
Collapse or folding code cell in Jupyter notebook
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...
Read more >
Collapsible Pane in Tkinter | Python - GeeksforGeeks
A collapsible pane, as the name suggests, is a pane which can be collapsed. User can expand pane so that they can perform...
Read more >
How To Collapse Cells In A Jupyter Notebook
When you create a new notebook, ideally you should see small triangles next to your code indicating that you can now collapse them...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found