马自立1 downloadsRemember how list items are folded by writing a Logseq-style collapsed:: true line into the note, hidden from view. The marker text is configurable.
Your lists stay folded the way you left them — written the way Logseq writes it.
An Obsidian plugin that remembers how each list item was collapsed, by writing a Logseq block property into the note instead of keeping the state somewhere outside it.
English · 简体中文
Logseq stores a folded block as a collapsed:: true property right under it. Obsidian does not understand that line: a vault that came from Logseq shows it as plain text, and Obsidian's own folds are forgotten as soon as the note is closed.
This plugin reads and writes that marker. The Logseq style is the default, so notes stay compatible with Logseq. If you prefer something else, set your own marker — an HTML comment <!-- collapsed:: true -->, an Obsidian comment %% collapsed:: true %%, or any line of text you like.
Fold something in a list, close the note, come back tomorrow — it is still folded.
- Weekly meeting
collapsed:: true
- Data sources
- Definitions check
- To do
- Not folded yet
The marker sits one indent level in, right under the item it belongs to — the same place Logseq puts it. Whatever style you choose, the plugin hides it everywhere you look:
collapsed:: true). A %% … %% comment is never rendered by Obsidian in the first place.Nothing else about your note changes.
| Style | Written as | Notes |
|---|---|---|
| Logseq (default) | collapsed:: true |
Same as Logseq; notes round-trip between the two apps |
| HTML comment | <!-- collapsed:: true --> |
Invisible in any Markdown renderer — GitHub, static-site generators, other editors |
| Obsidian comment | %% collapsed:: true %% |
Invisible in Obsidian even without the plugin, but other renderers show it as text |
| Custom | any single line, e.g. [folded] |
Written as-is under each folded item |
collapsed:: lines are always recognised — bare, inside %% … %% or inside <!-- … --> — whichever style you write, so switching styles never loses existing folds. collapsed:: false (which Logseq can leave behind) is treated as unfolded and is reused when you fold that item again.
If your notes are also published or read outside Obsidian — a blog, a GitHub repo, a static site, another editor — pick the HTML comment style:
Clean everywhere. Every Markdown renderer drops HTML comments, so the published page shows no trace of your folds. A bare collapsed:: true or an Obsidian %% … %% comment would show up there as text.
Easy to remove for good. The markers are a fixed, unambiguous pattern, so one regex search-and-replace across the vault (with multiline mode on) deletes them all and leaves everything else untouched:
^[ \t]*<!--[ \t]*collapsed::[ \t]*(?:true|false)[ \t]*-->[ \t]*\r?\n
Replace with nothing. Only whole marker lines match; the same text inside a sentence is left alone. For a single note, the Remove all fold markers from this note command does the same.
The folding itself is not drawn by this plugin — it calls the same CodeMirror fold that ⌥S uses. You get Obsidian's own arrow, the … at the end of the line, the same click to unfold.
Marker and fold are kept in sync in both directions:
app.plugins.plugins["logseq-style-fold"].quietly(() => …), and those folds are not recorded as yours.A JSON file in the plugin folder, keyed by line numbers or text hashes, falls apart on a note that keeps being rewritten: line numbers shift the moment anything is inserted above, and hashes break when the wording changes. A line written into the note travels with its own content through git, sync, export and any rewrite that keeps the block itself.
| Command | What it does |
|---|---|
| Fold or unfold the list item at the cursor | Toggle the item the cursor is on (an item without children cannot be folded) |
| Fold every list item in this note | Fold everything at once |
| Unfold every list item in this note | Unfold everything |
| Fold only top-level list items | Fold the outermost items, leaving inner levels as they are |
| Remove all fold markers from this note | Delete every marker — back to the text as it was before the plugin |
| Show or hide fold markers | Show marker lines as plain text, for checking what is in the file |
Bind any of them to a hotkey in Settings → Hotkeys.
| Setting | Default | What it does |
|---|---|---|
| Marker style | Logseq | Logseq collapsed:: true, HTML comment <!-- collapsed:: true -->, Obsidian comment %% collapsed:: true %%, or a custom line |
| Show a fold button on hover | On | An unfolded item shows a small collapse button at the end of its line while hovered |
| Show descendant count on the fold button | On | ⌄ 3 instead of ⌄ |
| Fold in Reading view | On | Honour the markers in Reading view, with a clickable badge to unfold |
| Fold in Source mode | Off | Source mode hides the marker either way; turn this on to fold there too |
| Show fold markers | Off | Show marker lines as plain text for checking |
Copy main.js, manifest.json and styles.css into <vault>/.obsidian/plugins/logseq-style-fold/, reload Obsidian, and enable Logseq Style Fold in Settings → Community plugins. Or add it through BRAT from MatsuriMW/logseq-style-fold.
collapsed:: true shows up as text — which is exactly what Logseq expects. Pick the HTML comment style if you want it invisible everywhere else.