Auto Headings

by AArlert
5
4
3
2
1
Score: 52/100

Description

Automatic heading numbering with fully customizable templates, per-folder rules, whitelist and backlink sync. Bilingual UI (English / 中文).

Reviews

No reviews yet.

Stats

6
stars
2,040
downloads
3
forks
78
days
8
days
9
days
7
total PRs
0
open PRs
0
closed PRs
7
merged PRs
2
total issues
0
open issues
2
closed issues
172
commits

Latest Version

9 days ago

Changelog

1.2.1 re-publishes 1.2.0 for the Obsidian community directory (plugin description wording only; no code changes). If you are upgrading from 1.1.x, everything below is new.

1.2.1 是 1.2.0 面向 Obsidian 社区插件目录的重新发布(仅改了插件简介措辞,代码无改动)。从 1.1.x 升级的话,下面的内容都是新的。

Display-only numbering mode / 仅显示编号模式

English

Auto Headings can now number your headings without ever touching the file.

  • New: display-only mode. Each path rule has a new Mode column: Write to file (the existing behavior) or Display only. In display-only mode the numbers are drawn in Live Preview, Reading view, embeds, hover previews and Obsidian's built-in "Export to PDF", and your notes stay byte-for-byte unchanged. Both modes share the same templates, whitelist and skip rules, so the numbers are identical.
  • Defaults. New installs start in display-only mode. Existing vaults keep "Write to file" and behave exactly as before — nothing changes until you pick a new mode.
  • Switching modes is safe. Changing a rule's mode (or deleting a rule, editing its path, or setting it to "No numbering") first shows how many notes are affected. Going from write to display-only can remove the numbers the plugin wrote — only its own numbers; hand-written ones stay — and links to those headings are updated. Going the other way can write the numbers right away or on the next edit. Cancel leaves everything as it was.
  • Links still follow your headings. Renaming a heading in a display-only note updates the links pointing to it, just like in write mode.
  • Leftover numbers are flagged, not hidden silently. If a display-only note still contains numbers the plugin wrote earlier, you'll see a single, dotted-underlined number with an explanation on hover, plus a new command: Clear leftover plugin numbering in this file.
  • Source mode shows your text as written, without display-only numbers.
  • Numbers in the Outline pane. Display-only numbers also appear in Obsidian's built-in Outline pane (turn this off under Settings → General → Show numbers in the outline). They are still not visible in in-file search, Obsidian Publish, GitHub or other editors — use Write to file for those.
  • Two new commands. Copy numbered outline copies the note's headings with their numbers as an indented list; Copy link to current section copies a link to the heading your cursor is under. Both work in either mode.
  • Clearing the whole vault keeps links working. Clear numbering in the whole vault now also updates links that point to the cleared headings (when Sync internal links is on). It and Freeze numbering no longer risk overwriting unsaved edits in notes you have open.
  • Fixed: the start of a heading could be deleted. When a heading contained a link to a numbered heading (e.g. ## See [[Note#1 Overview]]), numbering it removed everything before the link's anchor; the bundled Pandoc export filter had the same problem. Both are fixed, and Clean up non-plugin numbering and the migration prompt are no longer thrown off by such links.
  • Other: plugin settings reload automatically when data.json is changed by a sync service; "Freeze numbering and release ownership" now explains that display-only numbers disappear after freezing.

中文

Auto Headings 现在可以给标题编号,同时完全不改动你的文件。

  • 新增:仅显示模式。 路径规则多了一列模式:「写入文件」(原有行为)或「仅显示」。仅显示模式下,编号显示在实时预览、阅读视图、嵌入、悬浮预览和 Obsidian 内置的「导出为 PDF」里,笔记文件一个字节都不改。两种模式共用同一套模板、白名单和跳级规则,编号完全一致。
  • 默认值。 新安装默认「仅显示」。已经在用的库保持「写入文件」,行为与升级前完全一样,除非你自己改模式。
  • 切换模式有保护。 改某条规则的模式(或者删规则、改路径、改成「不编号」)时,插件会先告诉你有多少篇笔记受影响。从写入切到仅显示,可以选择清除插件写入的编号——只清插件自己写的,手写编号不动——指向这些标题的链接会一起更新;反过来可以选择立即写入,或者等下次编辑再写。点取消则一切照旧。
  • 链接照样跟着标题走。 在仅显示的笔记里改标题,指向它的链接同样会更新。
  • 残留的旧编号会提示,不会悄悄藏起来。 仅显示的笔记里如果还留着插件以前写的编号,界面上只显示一层带虚线的新编号,鼠标停上去有说明;另有新命令「清除本文件残留的插件编号」。
  • 源码模式只显示原文,不显示虚拟编号。
  • 大纲面板也有编号。 仅显示的编号也会出现在 Obsidian 自带的大纲面板里(可在「设置 → 全局设置 → 在大纲中显示编号」关掉)。文件内搜索、Obsidian Publish、GitHub 和外部编辑器里仍然看不到,需要这些场景请用「写入文件」。
  • 两条新命令。 「复制编号大纲」把本篇的标题连同编号按层级复制下来;「复制当前小节链接」复制光标所在小节的链接。两种模式都能用。
  • 清除全库后链接不再断。 「清除全库编号」现在会一起更新指向这些标题的链接(「同步内部链接」开启时);它和「固化编号」也不会再覆盖已打开笔记里尚未保存的改动。
  • 修复:标题开头的文字可能被删掉。 标题里含有指向已编号标题的链接时(如 ## 参见 [[笔记#1 概述]]),编号会把链接锚点之前的文字整段吃掉;随插件附带的 Pandoc 导出过滤器也有同样问题。两处均已修复,「清理非本插件的标题编号」和迁移提示也不再被这类链接干扰。
  • 其他:data.json 被同步服务改动后,插件设置会自动重新载入;「固化编号并交还所有权」的说明补充了仅显示的编号固化后会消失。

README file from

Github

Auto Headings

English | 简体中文

Automatic heading numbering for Obsidian that keeps up with you. Add, delete or move a section and the numbers fix themselves. Rename a heading and the links to it keep working.

Why Auto Headings

  • Can leave your files untouched. By default the numbers are only displayed inside Obsidian and your notes are never changed. When you need the numbers to travel with the file (GitHub, Publish, other editors), switch that folder to "Write to file".
  • Numbers that fix themselves. Insert a section in the middle of a long note and everything after it renumbers.
  • Links that don't break. Rename a heading and the [[note#heading]] links pointing to it are updated too.
  • Any style you like. 1.1.1, 第一章, 一、, ①, I., a), and more. You can give each folder its own style.
  • Skips what shouldn't count. "Contents", "Appendix" and "References" stay unnumbered and don't use up a number.
  • Works everywhere. Desktop and mobile, with the interface in English or 中文.

Quick start

  1. Install Auto Headings from Settings → Community plugins and enable it.
  2. Open a note and start typing. Headings from ## down show 1, 1.1, 1.1.1… in front of them, and the file itself stays unchanged.
  3. That's it. Open Settings → Auto Headings to change the style, or to write the numbers into your notes.

Features

Display only, or write to file

Each path rule picks its own mode:

  • Display only (the default for new installs): numbers appear in Live Preview, Reading view, the Outline pane and PDF export, and the note file is never changed. Source mode shows your text exactly as written.
  • Write to file: numbers are written into the note as real text, so they also show up on GitHub, in Obsidian Publish and in other editors.

Both modes use the same templates and produce the same numbers. You can switch at any time; the plugin first tells you how many notes are affected, then removes or writes the numbers as you choose. Vaults upgrading from an earlier version keep "Write to file".

Hands-free numbering

In display-only mode the numbers update live as you type. In write mode, numbering runs quietly after you pause typing, and one Ctrl/Cmd+Z undoes it. Either way only the note you're editing is processed, and your heading levels (#, ##, ###) are never changed.

## 2 Getting started      →   ## 2 First steps
[[guide#Getting started]]  →   [[guide#First steps]]

Change a heading's text and the links to it across your vault update at the same time. This covers wiki links and Markdown links, including links in note properties, and you can turn it off at any time.

A template for every kind of note

Pick a numeral style, prefix and suffix for each heading level and watch a live preview as you go. Then pick a template for each folder: academic numbering in Papers/, chapter numbering in Book/, none at all in Journal/.

Leave headings out

A built-in list keeps headings like "Contents", "Appendix" and "References" unnumbered, in both English and Chinese. You can add your own entries, or exclude a whole section together with everything under it.

Start typing the name of a heading anywhere in your vault and a suggestion pops up. Press Tab to turn it into a link.

Take over existing notes

Notes with hand-typed or imported numbering can be cleaned up with one command, then renumbered automatically from there on.

Commands

Command What it does
Renumber now Renumber the current note right away
Clear numbering in current file Remove all numbering from the current note
Clear non-plugin heading numbering Remove hand-typed or imported numbering only
Clear leftover plugin numbering in this file In display-only mode, remove numbers the plugin wrote earlier
Toggle global auto-numbering Turn automatic numbering on or off for the vault
Copy numbered outline Copy the note's headings as an indented, numbered outline (write or display-only mode)
Copy current section link Copy a link to the section under the cursor (write or display-only mode)

FAQ

Will it edit notes I'm not working on? Only in two cases: when you rename a heading that other notes link to (link sync, which you can switch off), or when you confirm a bulk action in settings, such as removing or writing numbers while switching modes.

Does it add anything hidden to my notes? Not in display-only mode. In write mode, one thing: each number carries an invisible marker character, which is how the plugin tells its own numbers apart from your text. It doesn't show up anywhere, and it's removed automatically when you copy text out of Obsidian. The user guide explains what this means for search, Dataview and Pandoc.

Is it heavy on resources? No. The plugin makes no network requests and collects no data. When it starts, it reads the headings in your vault once, locally, for "link to any heading as you type" (you can turn that off in settings); after that, numbering only touches the note you're editing. Memory use is capped: at most 50,000 indexed headings and about 2 MB of clipboard cache.

Can I stop using it later? Yes. Display-only mode never changed your files, so you can simply uninstall. If you used write mode, Settings → Sensitive actions lets you either remove all numbering or keep the numbers as plain text. Both work across the whole vault.

I'm coming from Number Headings. Disable it, enable Auto Headings, then run Clear non-plugin heading numbering on your old notes. Folder exclusion and skipping headings inside comments both work out of the box.

Can I use it together with another auto-numbering plugin? No. Two numbering plugins will fight over the same headings, so enable only one.

Install

  • Community plugins (recommended): Settings → Community plugins → Browse, search for "Auto Headings", then install and enable it.
  • Manual: download main.js, manifest.json and styles.css from the latest release into <vault>/.obsidian/plugins/auto-headings/, then reload Obsidian.

Learn more

  • User guide: every setting and edge case, export and Pandoc tips, and a clean-uninstall walkthrough.
  • Issues: bug reports and feature requests are welcome.

License

MIT