2026-06-21 Obsidian Vim Clipboard and Copy-Note Plugin
What I set out to do
Fix a long-standing annoyance: yank in visual mode in the Obsidian vault wasn’t landing in the system clipboard. Then, separately, add a way to copy a whole note’s contents for copy/paste of full notes.
What I actually did
Clipboard fix. Traced it through the obsidian-vimrc-support plugin: it keeps yank in vim’s internal register unless clipboard is set to unnamed/unnamedplus (main.js defaults yankToSystemClipboard = false). The .obsidian.vimrc is a Home Manager mutableFile deployed from nix/home-manager/files/obsidian/vimrc, so I edited the Nix source (not the vault copy) to add set clipboard=unnamed, then hm switch.
Copy-note command. First reflex was a keybind, but the ask was a command-palette entry. Went down two wrong paths before the right one:
- Templater insert-template registered as a hotkey command. Works, but it’s a hack: misleading “Insert” name and a real footgun (running it with text selected deletes the selection, since it’s an empty insert).
- Commander was the next idea, but checking its source (
src/types.ts) showed its macro engine only has COMMAND/DELAY/EDITOR/LOOP actions, no JS, no clipboard. It can only re-surface existing commands, so it couldn’t do the copy at all.
Landed on a ~15-line local Obsidian plugin (copy-note): addCommand with an editorCallback doing navigator.clipboard.writeText(editor.getValue()). Clean palette entry, editor-scoped (no footgun), fully declarative via obsidian.nix (source main.js + Nix-generated manifest.json + id in the community-plugins list). Reverted the Templater changes and manually removed the orphaned vault file, since home.mutableFile deploys real files and doesn’t GC them on removal.
Tested both, then committed as two atomic commits (1eb71d2 clipboard fix, 88dfa4f copy-note plugin).
What was striking
- The “obvious” tools (Templater, Commander) were both wrong for adding a real command-palette command. Reading Commander’s source instead of trusting its README is what killed that path quickly.
home.mutableFilenot cleaning up orphaned files is a quiet gotcha worth remembering: un-managing a vault file leaves it behind.- Systematic debugging paid off: reading the plugin’s
main.jsgave the exact one-line fix instead of guessing at vim settings.