Math Chords: Customizable LaTeX Math Shortcuts for Obsidian

· Chinese version
Last updated on

When taking academic or teaching notes in Obsidian, I often need to enter a lot of math. Typing \frac, Greek letters, and delimiters by hand is slow and error-prone. I wanted something closer to LyX’s shortcut-driven math input, so I vibe-coded an Obsidian plugin called Math Chords with Cursor.

Source and releases: github.com/ichenh/obsidian-math-chords


Version License: MIT CI

Math Chords lets you insert LaTeX formulas in Obsidian with keyboard shortcuts: press a configurable leader key, then a short key sequence to insert snippets—without typing complex LaTeX by hand. Also includes inline MathJax preview and display-math environment wrapping.

Default shortcuts are inspired by LyX math-mode bindings.

Current release: v0.1.0. See CHANGELOG.


Table of contents


Features

FeatureDescription
ShortcutsPress a configurable leader key, then a key sequence to insert LaTeX snippets.
Caret placeholder$$ in a command template marks where the cursor (or selection) is placed, e.g. \frac{$$}{}.
Auto $…$ wrapOptional: when inserting outside math, wrap the snippet in inline math delimiters.
Inline live previewWhile the caret is inside $…$, a floating panel above the formula renders with Obsidian’s native MathJax.
Display-math environmentsInside $$…$$, wrap existing content with \begin{…}…\end{…} via a fuzzy-search picker.
Built-in math commandsCtrl+M inline math, Ctrl+Shift+M display math (Obsidian commands, registered by this plugin).
YAML + UI configEdit shortcuts.yaml or use the settings tab; changes rebuild the shortcut trie immediately.
Non-destructive mergeOn load, missing default shortcuts are merged in; your custom key bindings are never overwritten.

Installation

Manual

  1. Download or build main.js, manifest.json, and styles.css.
  2. Copy them into <vault>/.obsidian/plugins/obsidian-math-chords/.
  3. Optionally copy shortcuts.yaml (defaults are created automatically if the file is missing).
  4. Enable Math Chords under Settings → Community plugins and reload Obsidian.

From source

git clone https://github.com/ichenh/obsidian-math-chords.git
cd obsidian-math-chords
npm install
npm run build

Copy main.js, manifest.json, styles.css, and shortcuts.yaml into your vault plugin folder.


Quick start

  1. Place the caret in a Markdown note.
  2. Press the leader key (default Alt+M; configurable in settings) — optionally enable the which-key popup.
  3. Press a shortcut, e.g. F\frac{}{} with the cursor in the numerator.
  4. For Greek letters: G A\alpha (after the leader).
  5. For display math: D$$\n\n$$.
  6. Inside $$…$$, press Shift+E (default, after the leader) to pick an environment and wrap the block content.

Note: Shortcut tables list keys after the leader. The default leader is Alt+M.


Shortcut reference

Structures & display math

KeysInsertsDescription
F\frac{}{}Fraction
S\sqrt{}Square root
Shift+R\sqrt[]{}Nth root
^^{}Superscript
Shift+__{}Subscript
D$$…$$Display math block

Operators & symbols

KeysInsertsDescription
U\sumSum
I\intIntegral
Shift+I\int_{}^{}Integral with limits
Y\ointContour integral
P\partialPartial derivative
Shift+P\prod_{}^{}Product
L\lim_{}Limit
8\inftyInfinity
''Prime
+\pmPlus-minus
= |\neqNot equal

Accents

KeysInsertsDescription
"\ddot{}Double dot
H\hat{}Hat
\\grave{}Grave
/\acute{}Acute
&\tilde{}Tilde
-\bar{}Bar
.\dot{}Dot
Shift+V\breve{}Breve
Shift+U\check{}Check
V\vec{}Vector arrow
_\underline{}Underline
B\overline{}Overline
A W\widehat{}Wide hat

Delimiters

KeysInsertsDescription
(\left(\right)Parentheses
[\left[\right]Square brackets
{\left\{\right\}Curly brackets
<\left\langle\right\rangleAngle brackets
>\left)\right(Reverse parentheses
|\left|\right|Vertical bars
B N\left|\right|Norm
B F\left\lfloor\right\rfloorFloor
B E\left\lceil\right\rceilCeiling

Greek letters — lowercase (G + key)

KeysInsertsKeysInserts
G A\alphaG N\nu
G B\betaG O\omega
G C\chiG P\pi
G D\deltaG Q\vartheta
G E\epsilonG R\rho
G F\phiG S\sigma
G G\gammaG T\tau
G H\etaG U\upsilon
G I\iotaG V\theta
G J\varphiG X\xi
G K\kappaG Y\psi
G L\lambdaG Z\zeta
G M\mu

Greek letters — uppercase & variants (G Shift+ + key)

KeysInsertsKeysInserts
G Shift+D\DeltaG Shift+S\Sigma
G Shift+E\varepsilonG Shift+T\varsigma
G Shift+F\PhiG Shift+U\Upsilon
G Shift+G\GammaG Shift+V\Theta
G Shift+L\LambdaG Shift+O\Omega
G Shift+P\PiG Shift+X\Xi
G Shift+Y\Psi

Extensions

Arrows (W prefix): W R \rightarrow, W L \leftarrow, W Shift+R \Rightarrow, W Shift+L \Leftarrow, W M \mapsto

Operators (O prefix): O T \times, O C \cdot, O D \div, O E \equiv, O L \leq, O G \geq, O A \approx, O I \in, O U \cup, O Shift+U \cap, O Shift+N \nabla

Fonts (T prefix): T B \mathbf{}, T C \mathcal{}, T R \mathrm{}, T Shift+R \mathbb{}, T T \text{}

Matrices (M prefix): M P pmatrix, M B bmatrix, M C cases

The full list lives in shortcuts.yaml (101 default shortcuts).


Display-math environment wrap

Inside a display-math block $$…$$:

  1. Press the configured shortcut after the leader (default Shift+E).
  2. Choose an environment from the fuzzy-search list.
  3. The plugin wraps the entire block content (not only the selection), e.g.
    $$\alpha+\beta$$$$\begin{aligned}\alpha+\beta\end{aligned}$$

Configure environments (name / \begin{…} / \end{…}) and the trigger keys under 行间公式环境包裹 in settings, or run the command Wrap display math with environment from the palette.

Default environments: aligned, matrix, cases, gathered.


Configuration

shortcuts.yaml

Shortcuts are a YAML array. The leader key is global (settings), not per entry.

- keys: "F"
  command: "\\frac{$$}{}"
  name: "Fraction"
  group: "Structures"

- keys: "G A"
  command: "\\alpha"
  name: "alpha"
  group: "Greek"
FieldRequiredDescription
keysyesKey sequence after the leader. Space-separated tokens; modifiers use + (Shift+S, G A).
commandyesLaTeX snippet. Use $$ once for the caret/selection position. Write \frac not \\frac in the settings UI (auto-normalized).
namenoLabel in the settings table and which-key popup.
groupnoGrouping label in the settings table.

Special command __DISPLAY_MATH__ inserts a $$…$$ block (used by D).

Key normalization

  • Keys are canonicalized to lowercase mod+base order: ctrlaltshiftmeta.
  • Letters are lowercase unless Shift is explicit (Shift+A).

Settings

Open Settings → Math Chords.

SettingDefaultDescription
Enable pluginonMaster switch for leader shortcuts.
Show hint popupoffWhich-key panel after the leader.
Inline math previewonMathJax preview above $…$.
Leader keyAlt+MGlobal prefix before shortcut keys; keys in YAML are what follows it.
Wrap outside mathonAuto-insert $…$ around snippets when not in math.
Display-math env wraponEnvironment picker inside $$…$$.
Env wrap keysShift+EKeys after the leader for the picker.
Math environments4 built-insEditable list for the picker.

Shortcut management: search, add, edit, delete entries; Reload re-reads YAML; Merge defaults appends any missing built-in shortcuts without overwriting yours.


Updating shortcuts

When the plugin loads (or you click Reload / 合并默认):

  1. Your existing YAML entries are kept as-is (same keys → same binding).
  2. Any default shortcut whose key sequence is not yet present is appended.
  3. The updated file is written back to shortcuts.yaml.

To reset completely, delete shortcuts.yaml and reload the plugin (a fresh default file will be seeded).

Regenerate the repo’s default YAML from TypeScript:

npm run seed

Project structure

obsidian-math-chords/
├── src/                    # TypeScript source
│   ├── main.ts             # Plugin entry
│   ├── leader.ts           # Leader shortcut state machine
│   ├── defaults.ts         # Default shortcut catalog
│   ├── config.ts           # YAML load/save/merge
│   └── …                   # math, preview, settings UI, etc.
├── shortcuts.yaml          # Shipped default shortcuts (101 entries)
├── styles.css              # Preview & settings styles
├── manifest.json           # Obsidian plugin manifest
├── esbuild.config.mjs      # Build config
└── scripts/seed-yaml.cjs   # Regenerate YAML from defaults.ts

Development

npm install
npm run dev    # watch build
npm run build  # typecheck + production bundle
npm run seed   # rewrite shortcuts.yaml from src/defaults.ts

Module layout and constraints: .cursorrules.

Pull requests welcome. Run npm run build before submitting.

Releasing

  1. Bump version in manifest.json and package.json; add the mapping to versions.json.
  2. Update CHANGELOG.md.
  3. Commit, then tag with the exact version (no v prefix), e.g. git tag 0.1.0 && git push origin 0.1.0.
  4. The release workflow builds and attaches main.js, manifest.json, and styles.css.

AI assistance

This repository was bootstrapped and maintained with AI-assisted coding tools (Cursor IDE and large language models) under human review.

  • Full disclosure: AI-ASSISTANCE.md
  • Contributors using AI should review all output and mention it in PR descriptions.

License

MIT © CHEH Hua