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).


I’m in the same boat.

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


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?


  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!


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?

1 Like