Skip to content
| Marketplace
Sign in
Visual Studio Code>Visualization>MathCodeNew to Visual Studio Code? Get it now.
MathCode

MathCode

bogarrichard

|
2 installs
| (0) | Free
Renders code operators and subscripted variable names as pretty mathematical symbols — without modifying the file contents.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

MathCode — renders code as pretty math, purely visual, never edits your files

A VS Code extension that renders certain source-code patterns as pretty mathematical symbols — purely visually, using editor decorations. The file contents are never modified.

What MathCode renders: operators, superscripts, subscripts, matrix notation, abs/norm and Greek letters

Features

  • Comparison operators: <= → ≤, >= → ≥, == → =, != → ≠
  • Arrows: -> → →, <- → ←, <-> → ↔
  • Subscripts: names starting with an uppercase letter followed by an underscore and a suffix are rendered with the suffix as a subscript, e.g. X_i is shown as X with a small lowered i.
  • Superscripts: the power operator with a simple exponent (number or identifier) is rendered as a superscript: x**2 → x², r ** n → rⁿ, x**-1 → x⁻¹, and combined with the Greek rule x**alpha → x^α. **kwargs and f(**opts) are unaffected (no left operand), and the spacing must be symmetric, so Markdown **bold** in comments is left alone.
  • Matrix notation: A.T is rendered with a superscript T (transpose) and argument-less A.inv() / A.invert() calls with a superscript -1 (inverse). Calls like .T(...), longer attribute names like .Type and inv(...) calls with arguments are left alone.
  • Absolute value and norms: bare abs(x) calls are rendered as |x| and bare norm(x) calls as ‖x‖; a simple second norm argument becomes a subscript: norm(M, 2) → ‖M‖₂, norm(M, 'fro') → ‖M‖ with a fro subscript. Qualified calls (np.linalg.norm(...)) and method calls (s.abs()) are intentionally left alone — import the bare name (from numpy.linalg import norm) to opt in. Calls with a complex second argument or more than two arguments are untouched.
  • Greek letters: Greek letter names are rendered as Greek characters when they stand alone as a whole identifier (alpha → α, math.pi → math.π — including the lambda keyword → λ) or carry a trailing underscore (lambda_ → λ). Greek bases of subscripted names are replaced too: Sigma_k → Σ with a subscript k, sigma_i → σ with a subscript i, alpha_max → α with a subscript max. Uppercase names are only replaced when the Greek capital is visually distinct from the Latin letter (Γ Δ Θ Λ Ξ Π Σ Φ Ψ Ω).

Lines containing the cursor or a selection are shown with the original text so editing stays predictable.

Usage

  • Works in Python files by default (mathcode.languages).
  • Toggle with the eye button in the editor title bar (shown for the configured languages), with the MathCode: Toggle command, or via mathcode.enabled.

Settings

Setting Default Description
mathcode.enabled true Enable/disable substitution.
mathcode.languages ["python"] Language ids where substitution is active.
mathcode.operators see above Operator → symbol map; fully customizable.
mathcode.greekLetters true Enable Greek letter rendering (lambda_ → λ, Sigma_k → Σₖ).
mathcode.superscripts true Enable superscript rendering of the power operator (x**2 → x²).
mathcode.matrixNotation true Render .T as ᵀ and .inv()/.invert() as ⁻¹.
mathcode.absNorm true Render bare abs(...) as |...| and bare norm(...) as ‖...‖.
mathcode.subscripts true Enable subscript rendering.
mathcode.subscriptIgnoreAllCaps true Skip all-uppercase names (MAX_VALUE) — treat them as constants, not subscripts.

Caveats

  • Substitution is purely textual: it also applies inside strings and comments, and a<-b (meaning a < -b) is rendered as an arrow. Greek names in prose (e.g. "beta release") are rendered too; use the eye button or mathcode.greekLetters if that gets in the way.
  • ALL_CAPS constants such as MAX_VALUE are skipped by default (see mathcode.subscriptIgnoreAllCaps); set it to false to subscript them too.

Development

npm install
npm run compile   # or: npm run watch

Press F5 in VS Code to launch an Extension Development Host, then open examples/demo.py to see the substitutions in action.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft