Code Emphasis

approvedunreviewed

by elfmedy

Highlight important code and comments in your notes.

↓ 293 downloadsUpdated 5d agoMIT

Code Emphasis

中文

Mark the important parts of code in your Obsidian notes, so they are easier to revisit.

Live Preview with highlighted code

Highlight text

  1. Select text inside a code block.
  2. Run Code Emphasis: Highlight selected text from the command palette.
  3. Optionally assign a shortcut in Settings → Hotkeys.

You can also type the markers yourself:

^^// Initialize before starting^^
if (^^status^^ == READY) {
    ^^Start()^^;
}

Selecting multiple lines highlights each nonblank line. To remove a highlight, delete its two ^^ markers, or undo immediately after adding it.

Reading and editing

  • Live Preview: markers stay hidden until you move the cursor into a highlight or select across it. Only that fragment opens for editing.
  • Reading view: shows highlights without markers.
  • Source mode: shows the original markers.
  • Copy code: the Reading view button removes markers and keeps your comments, indentation and backslashes. Normal editor copy keeps the selected source.

Code and comments use the same style. Backslashes stay unchanged: \^^fff^^ displays and copies as \fff. Highlights cannot span line breaks or nest; unmatched markers stay visible. Paired literal ^^ are treated as markers.

Settings

  • Language: Follow Obsidian (default), 中文, or English.
  • Font color: red by default. Switch off to keep the original text colors.
  • Background color: off by default. Enable to choose a color.

Both colors can be switched off independently. Restore defaults resets all settings.

Install

Requires Obsidian 1.13+.

BRAT: add elfmedy/code-emphasis and enable Code Emphasis.

Manual: download main.js, manifest.json, and styles.css from the latest release. Put them in your vault's .obsidian/plugins/code-emphasis/ folder, then enable the plugin.

The highlight command currently works in ordinary top-level fenced code blocks. Special blocks such as Mermaid are excluded.

Upgrading from the old HTML plugin · Development · MIT license

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.