README file from
GithubAuto Numbered Headings
Automatically numbers headings in your Markdown notes as you type. This plugin uses CodeMirror 6's transactionFilter to update heading numbers in real-time. Unlike other plugins that only decorate headings, this plugin writes the numbers directly into your note content.
Description
The Auto Numbered Headings plugin provides transparent, real-time heading renumbering. It ensures your document structure remains consistent by automatically updating heading numbers as you move, add, or delete sections. Because it modifies the actual document text, the numbering is preserved across all Markdown editors and exports.
How it works
The plugin follows an opt-in pattern. It only manages headings that you have already started numbering. To activate auto-numbering for a section, prefix your heading with a number followed by a dot and a space.
The renumbering logic is implemented using CodeMirror 6's transactionFilter, allowing it to intercept edits and apply numbering changes in the same transaction. This ensures a smooth editing experience without flickering or undo-history fragmentation.
Plain headings like # My Title are ignored. Once you change it to # 1. My Title, the plugin takes over and ensures all subsequent headings in that document remain correctly numbered and ordered.
Usage
Opt-in pattern
Add a number and a dot to any heading to start auto-numbering:
# 1. Introductionactivates numbering for level 1 headings.## 1.1. Backgroundactivates numbering for level 2 headings.
Hierarchical numbering
The plugin supports multi-segment hierarchical numbering:
# 1. First Section## 1.1. Subsection### 1.1.1. Deep Section
Trailing dot behavior
The plugin follows specific rules for trailing dots to balance automatic management with manual control:
- Single-segment numbers (e.g.,
# 1.) keep their trailing dot after renumbering. - Multi-segment numbers (e.g.,
## 1.1) have their trailing dot removed after renumbering.
If a multi-segment heading becomes "unmanaged" because the dot was removed, simply re-type the dot at the end of the number to re-trigger the auto-numbering logic.
Settings
Access settings via Settings → Community plugins → Auto Numbered Headings.
-
Enable auto-numbering: Toggle the entire plugin on or off.
-
Numbering format: Choose between different styles:
- Hierarchical: Standard 1, 1.1, 1.1.1 format.
- Flat: Sequential 1, 2, 3 across all levels.
- Per-Level: Independent numbering for each heading level.
-
Separator: Customize the string between the number and the title. The default is ". ".
Installation
From Obsidian (recommended)
Once approved, install directly from within Obsidian:
- Go to Settings → Community plugins.
- Search for Auto Numbered Headings.
- Click Install, then Enable.
Manual installation
- Download
main.js,manifest.json, andstyles.cssfrom the latest release. - Create a folder named
auto-numbered-headingsin your vault's plugin directory:<VAULT_PATH>/.obsidian/plugins/auto-numbered-headings/. - Copy the downloaded files into that folder.
- Reload Obsidian and enable the plugin in Settings → Community plugins.
BRAT
- Install the BRAT plugin.
- Go to Settings → BRAT → Add Beta plugin.
- Enter
yu-zou/obsidian-auto-numbered-headings. - Click Add Plugin.
Development
To modify the plugin or build it from source:
- Clone the repository.
- Run
npm installto install dependencies. - Run
npm run devto start the build process in watch mode. - Run
npm run buildfor a production build.