Transclude Me (KM macro on OSX)

While curating one’s notes, it is not uncommon to realize that some portion of text in current note actually merits being its own new atomic ‘topic’ (note).

TranscludeMe makes this easy: it cuts the selected text, replacing it with a transclusion link to a new note that contains the cut selection.

TranscludeMe is a working proof-of-concept of a future Obsidian plugin (or better, feature), prototyped as a Keyboard Maestro macro.

For me, it works well enough as a macro to be useful today as is; as a feature or plugin no doubt it will be more robust and polished.

Warning: while I believe that simple undo in Obsidian will let you get back your original text selection, this macro does cut the text you select, so if this makes you nervous, wait for the feature/plugin version.

Installation

To use it, you must have Keyboard Maestro installed.

Assign a hotkey; I use hyper-T

TranscludeMe_v0.1.kmmacros.zip (11.3 KB)

Usage

In a note inside Obsidian, select the text you want to convert into its own note, and then tap the assigned hotkey.

You will be prompted with a dialog to confirm or edit the default note title; it defaults to whatever was the the first line of the selected text. This works especially well if the selected text starts with a heading.

Upon hitting ‘ok’, the selected text will be replaced with a transclusion link like this: ![[my topic]].

If you immediately toggle into Preview mode, you will see the original text, in place, but now via transclusion.

Note that if you determine that you made a mistake, or the macro ran into a problem and broke for some reason, you should be able to use Obsidian’s undo to back out the changes and return to your original text unblemished (though you will have to manually delete the new created note).

Also, if the title you choose for the new note already exists as a note in your vault, the new note will use the next available version of ‘Untitled’ (Obsidian’s default behavior). If this happens, it will be immediately evident in the link that gets inserted into your document, so you can navigate to the note and rename it.

Logic

For those who may not have OSX+Keyboard Maestro, but have access to some other macro utility, the essential logic flow of the macro is this:

Lmk any questions, hope this is useful to others.

9 Likes

I was just looking through your big list of OSX Automation things, and came across this - it’s exactly the reason I made my ‘from template’ plugin - select a bit of text, turn it into a new note, but with some helpers to pull some structure out of the selection and make different kinds of notes: GitHub - mo-seph/obsidian-note-from-template: Simple plugin to create Notes from a template, and fill in fields defined there