Auto Spacer

approved

by fanthus

This plugin has not been manually reviewed by Obsidian staff. Wrap mixed English segments with inline code and insert CJK-adjacent spaces.

14 downloadsUpdated 1d ago0BSD

English | 中文

Auto Spacer

Obsidian plugin for mixed CJK–English typography. Inserts spaces at CJK–Latin boundaries and wraps English segments in inline code.

Features

  • Detects mixed Chinese (including Japanese kana and kanji) and English text
  • Inserts spaces between CJK and Latin characters
  • Wraps English segments in `inline code`
  • Skips existing backticks, links, tags, and other Markdown structures
  • Formats the current selection, or the entire current line when nothing is selected
  • Optional toolbar button in the editor header

Usage

Command

Open the command palette and run 「中英混排:反引号包裹并补空格」 (Mixed CJK–English: wrap in backticks and add spaces).

Default shortcut: Cmd + Shift + S (macOS) / Ctrl + Shift + S (Windows / Linux).

Settings

Configure under Settings → Community plugins → Auto Spacer:

  • 显示顶部按钮 (Show header button): show the “中英混排格式化” action in the editor toolbar

Installation

Manual install from GitHub Release

  1. Download main.js, manifest.json, and styles.css from Releases
  2. Copy them into your vault:
YourVault/.obsidian/plugins/auto-spacer/
  1. Enable the plugin in Obsidian: Settings → Community plugins

Source files alone are not enough—you must build main.js or download the compiled artifacts from a Release.

Development

Requirements

  • Node.js 16 or later (18+ recommended)

Local development

git clone https://github.com/fanthus/obsidian-auto-spacer.git
cd obsidian-auto-spacer
npm install
npm run dev

npm run dev watches and compiles src/main.ts to main.js. Reload Obsidian after code changes to test.

Production build:

npm run build

Linting

ESLint is configured. Run:

npm run lint

You can also use the Obsidian rules package eslint-plugin-obsidianmd. A GitHub Action runs lint on pushes to all branches.

Releasing

This project uses release.mjs to build and create GitHub Releases. Obsidian downloads main.js, manifest.json, and styles.css from the release.

Repository: https://github.com/fanthus/obsidian-auto-spacer

Prerequisites

  1. Install Node.js (18+ recommended)
  2. Install GitHub CLI and sign in:
gh auth login
  1. Install dependencies:
npm install

First release

Set the target version in manifest.json (e.g. 1.0.0), then run:

npm run release -- --push

The script will:

  1. Run npm run build to produce main.js
  2. Create a git tag matching the version (e.g. 1.0.0—no v prefix)
  3. Push the branch and tag to GitHub
  4. Create a GitHub Release and upload main.js, manifest.json, and styles.css

Subsequent releases

Pick a bump type for your changes:

CommandVersion changeWhen to use
npm run release:patch1.0.01.0.1Bug fixes, small changes
npm run release:minor1.0.01.1.0New features, backward compatible
npm run release:major1.0.02.0.0Breaking changes

These commands bump the version, sync manifest.json and versions.json, build, publish, and push.

Update minAppVersion in manifest.json before releasing if you require a newer Obsidian version.

Common options

Preview steps without publishing:

npm run release -- --dry-run

Custom release notes:

npm run release -- --bump patch --push --notes "Fix spacing around punctuation."

Read notes from a file:

npm run release -- --bump patch --push --notes-file CHANGELOG.md

Replace an existing release (e.g. after a failed publish):

npm run release -- --push --force

Full help:

node release.mjs --help

Manual release (optional)

Without the script:

  1. Update version in manifest.json
  2. Add "newVersion": "minObsidianVersion" to versions.json
  3. Run npm run build
  4. Create a GitHub Release whose tag exactly matches version (e.g. 1.0.0)
  5. Attach main.js, manifest.json, and styles.css

Submit to the Obsidian community catalog

After a GitHub Release, submit your plugin on community.obsidian.md with the repository URL. See Submit your plugin.

Funding links

Set fundingUrl in manifest.json to show sponsorship options:

{
	"fundingUrl": "https://buymeacoffee.com"
}

Multiple links as an object:

{
	"fundingUrl": {
		"Buy Me a Coffee": "https://buymeacoffee.com",
		"GitHub Sponsor": "https://github.com/sponsors",
		"Patreon": "https://www.patreon.com/"
	}
}

API documentation

Obsidian plugin development: https://docs.obsidian.md

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.