Jacopo Gori20 downloadsHighlight selected lines in fenced code blocks without modifying the code itself.
Select Code Lines Highlighter is a self-contained Obsidian plugin that turns a mouse selection inside a fenced Markdown code block into a visible line highlight. It stores the selection as hl: metadata and never changes the code itself.
It is useful for terminal output, Nmap scans, logs, stack traces, configuration snippets, and other blocks where copying or rewriting content just to emphasize a few lines is undesirable.
[!IMPORTANT] Version 0.1.1 is the first release available from the official Obsidian Community Plugins directory.
hl: specification.hl: metadata without modifying the note.Given this block:
```text
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
445/tcp open microsoft-ds
```
Select the last two lines and run Highlight selected code lines. The result is:
```text hl:3-4
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
445/tcp open microsoft-ds
```
Only the opening fence changes. Run Remove highlight from selected code lines to subtract selected lines from the existing hl: value.
You can also right-click a selection inside a supported fenced code block. The context menu shows Highlight selected code lines and Remove highlight from selected code lines only when the selection can be handled safely. The entries stay hidden for normal note text, selections that touch a fence, unsupported nested blocks, multiple selections, and malformed hl: metadata.
To assign a shortcut, open Settings → Hotkeys, search for Highlight selected code lines, and choose your preferred key combination. You can assign a second shortcut to the removal command.
Open Settings → Community plugins → Select Code Lines Highlighter → Options to configure the highlight color and intensity, plus the color and width of the accent marker. Changes apply immediately in the editor and Reading view. Use Restore defaults to return to the original appearance.
The plugin includes its own renderer for the editor and Reading view. It does not require Codeblock Customizer, Code Styler, or a special theme. The portable hl: metadata remains compatible with other tools that understand the same syntax.
Requires Obsidian 1.5.0 or later.
main.js, manifest.json, and styles.css from the latest GitHub release.<your-vault>/.obsidian/plugins/select-code-lines-highlighter/.hl: values must contain only positive safe integers and ascending ranges such as 2,4-6.hl: tokens, and malformed metadata are rejected.Requires Node.js 18 or later and pnpm.
pnpm install
pnpm run build
pnpm run lint
pnpm test
The production bundle is written to main.js. The source structure and build configuration follow the current official Obsidian sample plugin conventions.
The plugin runs locally. It contains no telemetry, analytics, network requests, or data collection. It modifies only the opening fence of the code block targeted by the active editor selection.