Fold/Unfold headings up to specific level hotkeys

Currently there is only a hotkey to fold/unfold ALL headings.
It would be nice to have a hotkey for each level.
So if I press the “Fold/unfold to level 3”, it will fold levels 3, 4, 5 and 6, but not 1 and 2.

OneNote desktop version has something like this

16 Likes

I definitely agree. Also wanted to link to a related request I made: Hotkeys to fold/unfold levels below and all but current

Speaking of Onenote, I think Word’s Outline Mode could be an inspiration in the ability to only show or hide list items by indent level: Filter lists by indent level. Not sure how Obsidian might do this as it depends on styles. Perhaps a plugin could take advantage of headings under the hood to accomplish this, although I have nothing to base that on.

Good idea. Thanks.

1 Like

I like the idea.

Another idea is to be able to fold/unfold a specific level by pressing a key and the level’s corresponding number.

eg
Ctrl + 2 would fold/unfold the H2 level
Ctrl + 4 would fold/unfold the H4 level

2 Likes

Here’s another (refinement on the) idea.

Let’s take an example.

H1

H2

H3

H4

H5

H6


Case 1

I can fold a heading (and everything below it) by pressing its corresponding number.

  • In the first case, if I want to fold everything up to H2, I press 2.
  • In the second case, if I want to fold everything up to H5, I press 5.

What if we focused not on the actual headings, but the number of levels used?


Case 2

I can fold a level (and everything below it) by pressing its corresponding number. In the two cases, six headings are used, but only three levels.

  • In the first case, if I want to fold everything up to level 2, I press 2.
  • In the second case, if I want to fold everything up to level 2, I press 2.

Notice the difference?


Advantages of the second case:

  • It doesn’t matter what headings are used.
  • You don’t need to recognize which heading is which, like in the first case, which might be hard to do at a glance.
  • The levels are clearly displayed in the Outline, which would serve as a kind of map for folding purposes.

I made a little recording to show the power of emacs’ org-mode, I believe this has everything needed to make Obsidian folding features perfect!

It was hard to show exactly how it works in a short video like this, but long-story short.

  • I use tab to fold and unfold, and shift + tab to cycle through opening and closing all headings.

  • This is somewhat possible with Obisdian, but it’s not possible to map just tab as a hotkey unfortunately.

  • Org-mode folding feels natural, fast and intuitive (specially with vim-keybindings)


I truly believe Obisidan can get to this level of advanced folding.

Org-mode is able to do it with org files, but also with .md (markdown) files without any limitations.

Advantages and additional features

start a file with all headings folded

org mode allows to determine in the metadata (top of the file)
this type of settings per note

#+STARTUP: overview
#+STARTUP: content
#+STARTUP: showall
#+STARTUP: showeverything

org mode docs initial visibility

this allows the user to chose if everything should be folded by default (I do that 90% of the times)

Moving around content

With org-mode is super easy to move around folded content, around the document.

This can all be done with vim-style shortcuts.

(Currently obsidian struggles to move around content without messing up what’s inside a sub-heading)

my contribution

I created a snippet called Org-sidian bullets

Org-sidian Bullets ◉ Instead Of # For Headers (Inspired by org-mode)

this is more for the style of bullets (to replace #)

but unfortunately all the folding functionality cannot be controlled by this snippet I made, and my skill level doesn’t allow me to attempt a plugin to add this functionality (not sure if it’s even possible)


This feature is the only thing I have to go out of Obsidian to use my notes. If folding evolves I think it would make Obsidian so much better.

Thanks!

5 Likes

+1 for this feature request.

I think it would be even enough (if possible) to use only one hotkey for folding and by using this hotkey multiple times it always folds one header-level more, starting with the smallest header in the note. So you press it once, H6 folds, you press it twice, H5 folds and so on.

A different hotkey would be assigned for unfolding the same way.

2 Likes

+1 for this feature request from me, too.

My rationale:

  1. I migrate to Obsidian from MindMapping
  2. Obsidian is great, but with hundreds of notes (=nodes in my case) is overwhelming: without (un)folding I’m exposed to a lot of textual information, much more than 5-7 objects acceptable by human working memory
  3. In mind-maps I can (un)fold a given node only one level down. In Obsidian it depends on the former heading/indent state, but “unfolding” unfolds all the levels down.

My suggested reference model in Mind Manager, similar to org-mode mentioned by @santi.

So, if I could, I would give +10 for this feature :slight_smile:

2 Likes

@santi It might actually be possible, although globally, not context sensitive. Did you try this?

1 Like

this worked perfectly thank you for that, I was really in need for this! it might not be a user friendly way to do it, but it was pretty easy specially with a text editor that formats JSON nicely.

I would also love this feature, which I use heavily in OneNote. Here are the keyboard shortcuts there.


image

Related feature requests:

I think it may be nice to either have hotkeys or modifier clicks on the arrows to fold all levels beneath current, unfold all levels beneath current, fold all levels except those between current and its currently most unfolded sub-level, fold all except current, unfold all levels to the depth of current, etc…

I am sure there are some other good ones I don’t have here. Personally, I like modifier clicks on arrows. For example alt-click arrow may be good for fold all except this level. Ctrl-click arrow feels like unfold sub-levels could work. Some of the other more nuanced ones may benefit from hotkeys.

If this is already a topic, I apologize. I promise I did do a few searches. Thanks for everything.

Life is good; and so is Obsidian.

6 Likes

I would really like to see a feature similar to VS Code where level-specific collapsing is allowed.

The feature for them is implemented with Ctrl+1 for level 1, Ctrl+2 for level 2, etc. I would also love to see the option to fold different levels show up on the Ctrl+p menu.

This is an example of what I would like to accomplish using only the keyboard, instead of having to manually click every arrow:

Level 3 folded

11 Likes

I like this idea.

1 Like

My mistake, I always use the Ctrl+Shift+P menu to do it, so I just wrote what the shortcut says without thinking.

Command menu

What you actually have to do is the Ctrl+K command, then Ctrl+1 or Ctrl+2 based on what level you want. Sorry!

Bumper for a much needed request.

Adding to the tread, I would like:

the option to fold/unfold only the lists, a default setup for folding status every time I open a link (like always have unfolded H1 and H2 but the rest of headings and lists folded), and also the bug that when you have checklists folded but you check a checkbox from a different list, all checkboxes unfold.

Maybe a plugin that addresses this issue on the outline section could do, but it should also include the option of folding only lists (and checkboxes).

It really annoys me that the folding and unfolding is not remembered by the system.
I would love to stay folded even if I re-open it.

You will be happy to see that the feature you are requesting is implemented in 0.11.0 according to thread in this link here: Remembering heading and indent collapse in notes

However, this thread is about being able to quickly fold and unfold to a certain level. It is also a thread where some people’s requests for additional types of hot keys as they relate to folding have been merged. See here: Fold/Unfold headings up to specific level hotkeys - #12 by I-d-as . I make this distinction to avoid this thread being closed with this newly implemented feature that you are requesting.

I hope this is not interpreted that I am expecting this to be closed or that I am annoyed my request was merged here. I am just making it clear. I think the moderators do an excellent job on this forum and very much appreciate them!

Thanks.

Found this feature request while searching to see if heading-level folding shortcuts had already been requested (e.g. CTRL+1, CTRL+2… CTRL+6) . However I see Santi has done an excellent job of recording the many features associated with folding:

I agree these would be awesome.

2 Likes