Underliner

by gugu
5
4
3
2
1
Score: 50/100

Description

Obsidian plugin: Ctrl+U to underline the selection, Ctrl+U again to remove it. Zero settings, 3 KB, no build step.

Reviews

No reviews yet.

Stats

0
stars
112
downloads
0
forks
9
days
9
days
9
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
1
total issues
0
open issues
1
closed issues
4
commits

Latest Version

9 days ago

Changelog

Cursor support when nothing is selected.

Put the cursor inside a word and press Ctrl+U: that word is wrapped, and pressing again unwraps it. No need to select it first. On blank space the plugin still inserts an empty pair between the tags.

This is the remaining gap that the existing underline plugins have open as an issue ("works for selection, but not when the cursor is in the middle of a word").

Everything else is unchanged: multi-line selections are wrapped line by line, existing <u> pairs are removed instead of nested, and the command has no settings.

README file from

Github

Underliner

Ctrl+U to underline. Press it again to take the underline away.

Latest release License Size

Obsidian gives bold and italic a hotkey but not underline, because Markdown has no underline syntax. The only way is raw HTML:

This sentence has one <u>underlined</u> phrase in it.

Seven characters typed around every phrase, closed every time, forgotten often enough to be irritating. Underliner turns that into a single keystroke, and a toggle.

What it does

You do You get
Select important and press Ctrl+U <u>important</u>
Press it again important
Select text that is already inside <u> … </u> the tags are removed, no nesting
Put the cursor inside an empty <u>…</u> pair and press the pair is removed
Put the cursor inside a word, nothing selected that word is wrapped (press again to unwrap)
Press with the cursor on blank space <u></u>, cursor between the tags
Select several paragraphs each line wrapped on its own

Why this isn't a five-line snippet

Because the naive version breaks on real notes.

  • An inline HTML tag cannot span a line break. Wrapping a multi-line selection in one <u>…</u> silently breaks the rendering of the paragraph around it. Underliner wraps each line separately and leaves leading whitespace outside the tag, so it keeps working inside list items and blockquotes.
  • Pressing the hotkey twice should be a no-op. Underliner detects a surrounding pair — or any <u> pair contained in the selection — and removes it instead of nesting another one.
  • Nothing selected shouldn't do nothing. With the cursor inside a word, that word is wrapped — no need to select it first. On blank space it inserts an empty pair and drops the cursor between the tags.

Word detection covers ASCII words (letters, digits, _, -, '). It deliberately skips CJK text: Chinese and Japanese have no spaces, so guessing a word boundary there would wrap the wrong range — you get an empty pair to type into instead.

Install

Community directory

Submitted and under review. Once it's listed, install it from Settings → Community plugins → Browse.

BRAT (before that)

  1. Install and enable BRAT.
  2. Run the command BRAT: Add a beta plugin for testing.
  3. Enter guguthecoder/obsidian-underliner.

Manual

  1. Download main.js and manifest.json from the latest release.
  2. Put them in <vault>/.obsidian/plugins/underliner/.
  3. Reload Obsidian, then enable Underliner in Settings → Community plugins.

Hotkey

Ctrl+U (⌘+U on macOS) is bound as a default, so it works the moment the plugin is enabled. If something else claims it, rebind it in Settings → Hotkeys → Underliner: Toggle underline. On mobile, add the command to the editor toolbar in Settings → Mobile.

Already using another underline plugin?

There are older plugins that write <u> too. If one of them does everything you need, keep it — this isn't meant to replace something that already works.

It exists for the cases those ones get wrong, and which are still open issues in their trackers: the underline doesn't come off when you press the hotkey again, the toggle toggles something unexpected, a multi-line selection renders broken, the cursor inside a word does nothing, or a word at the end of a line is skipped.

Compatibility

  • Obsidian 1.4.0 and later, desktop and mobile.
  • Source mode, Live Preview and Reading view.
  • Only edits text when you run the command — the selection, or the word under the cursor. Notes are never modified on load.
  • Uninstalling leaves the <u> tags in your notes, as it should: they're ordinary text, and Obsidian renders them without any plugin.

Design notes

The plugin is a single 4.5 KB main.js with no dependencies, no settings tab, no stylesheet and no build step — open it, edit it, reload Obsidian. Underlining is native HTML, so the rendering is already there; there is nothing to style.

Underliner deliberately does not add a toolbar button, a formatting menu entry, a live-preview decorator, or tags like <center> / <sub> / <sup>. Those are the features that turn five kilobytes into five thousand lines.

License

MIT