Add hotkey binding for explorers' "Collapse all" action

Use case or problem

Since obsidian-collapse-all plugin is considered obsolete as its “Collapse all” / “Expand all” got incorporated into Obsidian’s core, it would be good to expose a hotkey bindings for it same as they were for the original plugin (see screenshot below).

For me personally it is one of most common hotkeys I used on a daily basis: I very often perform a following combination (all performed with keyboard hotkeys):

  1. “Reveal active file” in order to expand left sidebar and make it show “Files”
  2. “Collapse all”, because I realise there are many things open there and it is difficult for me to locate stuff visually
  3. “Reveal active file” once again to make current file visible and focused in “Files”

Proposed solution

Add hotkey bindings similar as they were exposed by obsidian-collapse-all plugin:

Current workaround

Install obsidian-collapse-all plugin and us its shortcuts, by cost of having 2 icons in Files/Tags/etc. instead of 1 and by cost of possible lack of future maintenance (since plugin is considered obsolete).

Related feature requests

It is same as Keyboard shortcut to collapse folders / collapse all which is already wrongly closed, because hotkey didn’t make to Obsidian 0.16 (1.0 now, if I understand correctly).

4 Likes

I’m in the same boat.

But perhaps we need a “Reveal active file, collapsing all other folders” command

3 Likes

Same request. Maybe this is forgotten~~

I’m not sure if this was implemented, but a possible workaround is to have a template with this: <%* document.querySelector('[aria-label="Collapse all"]').click() %>
and just create the command/shortcut to it

Could you elaborate a bit more on how to do so?

Sure…

  1. Install the Templater plugin and enable it
  2. In the templates folder you assign to Templater, create a file with this: <%* document.querySelector('[aria-label="Collapse all"]').click() %>
  3. In the Templater plugin settings, there is one setting where you can create a command for a specific template, you choose the template you created in step 2
  4. You then will see the new command in the command palette, if you go to Obsidian shortcut settings you can see there that you can assign a shortcut to any command you want.

And that’s it!

2 Likes

Hi guys! Any updates on this? I also would love to see a hotkey for this feature. We already have a button to collapse all folders. Why not add a shortcut for this?

3 Likes

I definitely need this, the number of files is getting way out of hand.

Hey, I did this but it’s not working. I made a keyboard shortcut and everything. Any clearer instructions?

I’m just going be annoying, because I am really suffering because this is not a Hotkey option.

How do we annoy the Obsidian team exactly?

See how long and out of hand it gets? I still feel like I’m at the beginning of developing out this vault.

In addition, I still can’t figure out how to prevent it from just randomly opening folders all over the place. My only solution now is to “over-use” the command + O and search. But sometimes it just drives me crazy.

Just install GitHub - nathonius/obsidian-collapse-all as mentioned at the top.
I’m still using its keyboard shortcuts and it works fine.

1 Like

Thanks for this! There are so many people making amazing things to help us all (the body of Christ). It’s difficult to acknowledge everyone, but I take this opportunity to say thank you—it works perfectly.