Obsidian: Creating new notes from clipboard using KM?

Is it possible?
Obsidian uses MD format, so it's not text format. I am wondering if anybody able to create note. Or even get KM display a text box to enter something I want to remember and KM will save it then as a new note.

MD is just Markdown, which is pure text. If you open a vault in Finder, you'll see that each note is just a text file, with an "md" extension, but it's pure text:

I'm not a regular Obsidian user, but it seems like it'd be pretty easy to do. As the notes are just text files, and Obsidian seems to recognize manually-added notes within a vault—even while it's running—your macro can just create a new file in the vault folder, named with a name ending in .md, and it'll show up in Obsidian.

Does that help/make sense?

-rob.

Here's a very basic proof of concept that asks for a title and some input, then creates the file in your vault. There is no error checking at all, which is not a good thing to do. For instance, if you enter the name of an existing note, then the macro will merrily write your new content over that file. That's not good, so some work should be done to make sure that the macro doesn't overwrite an existing file.

But this worked in my testing, even with Obsidian running.

Download Macro(s): New note in Obsidian.kmmacros (3.8 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.5
  • Keyboard Maestro v11.0.3

-rob.

I think it does make sense, that's why nobody is asking how to do it, if it's so easy :grinning:

I spent 2 hours trying high and low reading Obsidian forums and they give complicated answers. But I see, it's maybe because these guys trying to achieve more complex objectives here, along with creating notes etc...

And the only thing would be then if I want to preserve format, I need something like Clipdown to convert HTML to markdown.

But I need it most for simple text, so I think jus text file will work fine.

Very good. Thank you. That's helps.

Perfect this worked. That's what I wanted. Simple stupid and works.

One last question - this name-overwrite is a risk of course. Where can I add there in the flow a suffix generated out of date and time stamp.

Obsidian uses something like this to represent the time stamp.
YYYYMMDD-HHMMSSMMM

This would prevent any accidents. Even seconds would be enough, don't need milliseconds.

So the saved note would look like tis:

Title - YYYYMMDD-HHMMSS.md

This should work.

Download Macro(s): New note in Obsidian.kmmacros (4.1 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.5
  • Keyboard Maestro v11.0.3

-rob.

1 Like

That's a very nice solution. It does unfortunately have the limitation that typed string triggers cannot be used within it.

I have experimented a few times with using external Markdown notes editors (e.g. FSNotes) but somehow it always ends up simpler just to dump all new notes straight into the same page in Obsidian and then divide them into separate notes later.

It would be relatively trivial to have it work in TextEdit instead of using a Prompt for Snippet action, and then you could use whatever you like, I think. Tweaking…ok, yep. done :).

The attached version works with TextEdit, and typed string triggers work fine. It also now offers either a date or a six-digit alpha code (upper and lower case), which is shorter and almost guaranteed unique (1 in 19 billion some odd chance of a duplicate).

Launch the macro, enter a title and choose the unique ID option (date or random chars). TextEdit will open a new document. Type what you like, using Markdown symbols and KM typed string triggers, then press Shift-Command-Control when done.

Try it and see if it works for you.

Download Macro(s): New note in Obsidian via TextEdit.kmmacros (13 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.5
  • Keyboard Maestro v11.0.3

-rob.

1 Like

Good work, yes, that works surprisingly well.

For the body of the note, yes, but not the title.

It was interesting to see this and the preceding macro, but I do wonder whether it wouldn't be easier for @itoldusoandso to:

  1. Activate Obsidian (by personal choice of trigger).
  2. Press Cmd-N to create a new note.

Cmd-V would take care of the clipboard part of the original query... And of course all these and other simple actions could be put in a macro.

One reason to use an external mechanism to add a new note is if the user wants to bypass the "Default location for new notes" setting in Obsidian. For example, one could have new notes saved in an "inbox" folder yet still use cmd-N within Obsidian to create a new note within the current folder.

I'm pretty sure that's why I was experimenting with external MD editors some time back.

That’d also be pretty easy to do, though it would require following a rule in the editor - first line is title only, then two line breaks, then text.

Then you could split the title out with regex and be done.

I also wondered, but he had asked for a way to quickly take notes outside Obsidian. Me? I still use yellow stickies :).

-rob.

Yes yes .. please.. that is good ideal too, would it be a lot of trouble if I asked for the .. "That’d also be pretty easy to do, though it would require following a rule in the editor - first line is title only, then two line breaks, then text. Then you could split the title out with regex and be done."

I think I will use both macros. They are both good for me.

For the above approach typing title into the prompt window... it doesn't work for me, I get past the NoteTitle and then the TextEdit window opens and that's it. It seems Macro stops for me. It doesn't respond to the keypresses shift-control-command and it also doesn't display the progress bar at all.

To answer question .... would it be easier to just open Obsidian?
The answer is off topic here a bit but a here we go: No really for me, as I don't have it open often to preserve memory and CPU. Obsidian Helper does run high on CPU sometime like 15-25% without any sync being on .. sometimes.. who knows why, I have about 20-30 plugins installed, maybe that's why... Plugins also eat memory...

1 Like

This version lets you put the title and the content into TextEdit, in this format:

Title goes here

The content
goes
here and

blank lines **and** Markdown format

are all fine.

And it fixes the error if your TextEdit is already in plain text mode. (You can just copy the "Switch to plain text if not in that mode" group to the other macro, taking out the standalone Select Menu action.)

Download Macro(s): New note in Obsidian via TextEdit rev 2.kmmacros (17 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.5
  • Keyboard Maestro v11.0.3

-rob.

Perfect. Thank you. I am sure it's gonna be helpful for others.