I'm using Gooogle Colab to keep a record of code I learn whilst working through the 'Google IT Automation with Python' course.
I use the table of content feature to group sections of code by topic. These sections can be toggled in the main window to show or hide their content.
However, with so much code building up, I would like a way to quickly close all toggles e.g. as shown in the picture.
(Alternatively, if anyone has a better method or can recommend a better platform for building, testing and organising code snippets in a way that is easily retrievable, I'd welcome the recommendation).
Thanks!
Note: Updated the original answer in May 2024 since the original shortcut no longer works.
To open or close all sections in a Colab notebook at once, you first select all cells, then collapse/expand them.
Ctrl + Shift + A
: select all cellsCtrl + [
: expand selectionCtrl + ]
: collapse selectionPlease note that, in edit mode (when you have a blinking cursor), Ctrl + ]
and Ctrl + [
means "indent" and "dedent" respectively1.
You can find a list of all available commands at "Tools" menu -> "Command palette" (go ahead and have a glance; it's worth it!).
Ctrl + ]
invokes "Collapse all/select sections" in command mode (not editing a cell).
Ctrl + [
after hitting Ctrl + ]
expanded all cells in my experiment, but this is not documented.