VS Code Extensions
Markdown Number Title

Markdown Number Title

by jarvanstack

Automatically add hierarchical numbers to Markdown headings when a file is saved.

Downloads

14

Rating

5.0 / 5 (1)

Version

0.1.0

Last updated

Jul 10, 2026

Automatically add hierarchical numbers to Markdown headings whenever a file is saved.

中文说明

Features

  • Numbers ATX headings (# through ######) on save.
  • Keeps H1 as the unnumbered document title by default.
  • Produces hierarchical numbers such as 1., 1.1., and 1.1.1..
  • Recalculates existing generated numbers, so repeated saves are idempotent.
  • Ignores fenced code blocks, front matter, HTML comments, and script, pre, or style blocks.
  • Includes commands to update or remove numbers manually.
  • Has no runtime dependencies and does not send document data outside VS Code.

Example

Before saving:

# First-level heading

## Second-level heading

### Third-level heading

## Another second-level heading

After saving:

# First-level heading

## 1. Second-level heading

### 1.1. Third-level heading

## 2. Another second-level heading

The extension updates the open Markdown document before VS Code writes it, so the original file is overwritten with the numbered content.

Commands

Open the Command Palette and run:

  • Markdown Number Title: Update Heading Numbers
  • Markdown Number Title: Remove Heading Numbers

Settings

Setting Default Description
markdownNumberTitle.numberOnSave true Update heading numbers before each save.
markdownNumberTitle.startLevel 2 First heading level to number.
markdownNumberTitle.maxLevel 6 Deepest heading level to number.

To number H1 as well:

{
  "markdownNumberTitle.startLevel": 1
}

Local Development

npm install
npm test

Open this repository in VS Code and press F5 to launch an Extension Development Host.

To link the source checkout into local VS Code and Cursor extension directories:

./install.sh

Package and Publish

npm run package
npm run publish

Publishing uses the official @vscode/vsce tool and the jarvanstack Marketplace publisher.

License

MIT

Related extensions