Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Markdown Header FoldingNew to Visual Studio Code? Get it now.
Markdown Header Folding

Markdown Header Folding

Arron Eicholz

|
1 install
| (0) | Free
Fold and unfold sections of the Markdown preview at every heading level, like folding in the editor.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Markdown Header Folding

Fold and unfold sections of VS Code's Markdown preview at every heading level, # through ######, the way you fold them in the editor.

A Markdown file and its preview. In the preview, the "Test" and "After the release" sections are folded and the "Prepare" section shows its fold chevron.

Features

  • A fold chevron beside every heading in the preview. It appears when you point at the heading, and stays on folded headings, like the editor's folding controls.
  • Nested folding. Folding a section hides everything up to the next heading of the same or a higher level, subsections included. Sections you folded inside it stay folded when you open it again.
  • Shift+click a chevron to fold or unfold a section and every section inside it.
  • ⋯ after a folded heading. Click it to unfold.
  • Fold All, Unfold All and Fold Level 1–6, from the preview's right-click menu, the Command Palette, or the editor's folding shortcuts while the preview is focused.
  • Folds are remembered for each file, while you edit, when the preview switches between files, and after you close the preview or restart VS Code.
  • Find in the preview (Ctrl+F, ⌘F on macOS) searches folded sections too, and opens the ones around a match.
  • Scroll sync still works: moving through a folded section in the editor brings its heading into view in the preview.
  • Keyboard accessible: the chevrons are buttons. Tab to one and press Enter or Space.

Commands

Command Shortcut while the preview is focused
Markdown Header Folding: Fold All Headings Ctrl+K Ctrl+0 (⌘K ⌘0 on macOS)
Markdown Header Folding: Unfold All Headings Ctrl+K Ctrl+J (⌘K ⌘J)
Markdown Header Folding: Fold Level 1 (#) … Fold Level 6 (######) Ctrl+K Ctrl+1 … Ctrl+K Ctrl+6 (⌘K ⌘1 … ⌘K ⌘6)

The same commands are in the preview's right-click menu, with Fold Level as a submenu. Fold Level n folds every heading at that level and leaves other folds as they are.

From the Command Palette, a command applies to the preview of the Markdown file you're editing, or, if a preview is active, to the preview you used last.

Good to know

  • Needs VS Code 1.108 or later.
  • Only top-level headings fold. Headings inside block quotes, lists or raw HTML don't get a chevron.
  • Fold All, Unfold All and Fold Level briefly reload the preview: VS Code doesn't let extensions send messages to its built-in preview, so the command reaches it through a fresh render. Folding with the chevrons doesn't reload anything.
  • Folds are stored by heading text. Renaming a folded heading while its preview is open keeps it folded; renaming it while the preview is closed unfolds it.
  • Folds are stored in the preview's own browser storage, on your machine. The side preview (Markdown: Open Preview to the Side) and the preview editor (View: Reopen Editor With… → Markdown Preview) keep separate folds.
  • Folding the preview doesn't fold the editor, or the other way round: VS Code doesn't tell extensions what's folded in the editor.

Release notes

See CHANGELOG.md.

Development

Building, testing and releasing: docs/development.md.

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft