In case people still struggle with this, using a Mac the commands for the Cursor IDE are as follows:
Collapse all: CMD + R + 0 (zero)
Expand all: CMD + R + J
To collapse/expand only a class or method, click with your cursor on the class/method's name and then use these commands:
Collapse class/method etc.: CMD + R + [
Expand class/method etc.: CMD + R + ]