Outline Collapse

approvedunreviewed

by hibara

Collapse the core Outline view of the active file at a chosen heading level.

↓ 91 downloadsUpdated 23d agoMIT

Outline Collapse

A small Obsidian plugin that folds the core Outline view of the active note at a heading level you choose. Obsidian can collapse outline items one by one, but there is no way to say "show me H1 and H2 only" in a single step. That is what this plugin adds.

Features

  • Collapse the outline of the active note at H1, H2, H3, H4, H5 or H6 and deeper.
  • Expand the whole outline again.
  • Keep chosen headings open by name, with * wildcards, so a section you always want in view survives the fold.
  • Every level has its own command, so you can bind H2 to a hotkey and H4 to another.
  • Optional auto-collapse whenever a note is opened.
  • Optional ribbon icon.

Heading levels come from Obsidian's metadata cache, not from how deeply the rows are nested, so notes that start at H2 or skip a level still collapse at the level you asked for.

Commands

CommandWhat it does
Collapse outline at the configured levelUses the level set in the plugin settings
Collapse outline at H1 and deeperOnly the H1 rows stay visible
Collapse outline at H2 and deeperH1 and H2 stay visible, everything below is folded
... through H6
Expand the whole outlineUnfolds every heading

Settings

  • Collapse level - the level used by the main command, the ribbon icon and auto-collapse.

  • Unfold headings above the level - when on, headings above the collapse level are expanded first, so the outline always ends up showing exactly that level. Turn it off to only fold, and never unfold, what you already collapsed by hand.

  • Keep these headings open - a free-form list, one heading name per line. A heading whose name is on the list is never folded, and neither are the headings it sits under, so it always stays in view. A line has to match the whole heading, except that * stands in for any run of characters: 3. Part* keeps every heading that starts with 3. Part, and *TODO* keeps every heading with TODO anywhere in it. Matching ignores case, leading # marks are stripped so you can paste a heading straight out of your note, and lines starting with // are comments. Names that match nothing in a note are simply ignored, and a name that matches more than one heading keeps every one of them open.

    // sections I always want in view
    Open questions
    ## TODO
    3. Part*
    

    The headings below a kept one still follow the collapse level, so keeping Chapter B open shows its children without unfolding the whole branch.

  • Collapse on file open - apply the collapse level automatically when a note is opened. On by default; turn it off if you would rather collapse only by command.

  • Show ribbon icon - add a ribbon button for the main command.

Requirements

The core Outline plugin must be enabled and its view open (sidebar or elsewhere). If no outline view is open, the commands do nothing and show a short notice.

Manual installation

  1. Download main.js and manifest.json from the latest release.
  2. Copy them into <vault>/.obsidian/plugins/outline-collapse/.
  3. Reload Obsidian and enable Outline Collapse in Settings -> Community plugins.

Development

npm install
npm run dev    # watch build
npm run build  # type-check + production bundle

License

MIT

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.