# KM to set up new note?

Does anyone use a KM macro to set up a new note pre filled with certain information?

I'm using a very simple one to set up areas for keywords, references, etc, which works well. I create a new blank note, press a hotkey and it inserts a set of headers and placeholder tags.

Currently, though, I need to add in the title myself. What I would like is for it also to fill in the title area, with the title of the note on the first line as a header and self link on the next (am also open to advice / reminders about posts for good structures for notes)

I thought I might be able to work this out myself by adapting Will's 'insert note' KM but that has script in order to populate the pop up box and I can't work it out.

«1

• Okay, so I've worked out enough of Will's insert link macro (using information I found in another post on here to understand the sed statement a bit) to pretty much do what I need it to do. It's not elegant at all, it's presenting the full list of zettels are per Will's macro for me to select the one I've just created and then it manipulates the resulting variable to create the header and then add the rest of the stuff I mentioned.

Is there a more elegant way of doing the first part - of selecting the note I happen to be in?

• edited June 2020

I personally don't use KM so I can't help with that, but if you use Alfred on your Mac, I made a workflow which may interest you as it does this and more: https://github.com/pryley/alfred-the-archive/blob/master/README.md

• @pryley said:
I personally don't use KM so I can't help with that, but if you use Alfred on your Mac, I made a workflow which may interest you as it does this and more: https://github.com/pryley/alfred-the-archive/blob/master/README.md

You've just encouraged me to spend money (on the powerpack)

I'm playing around with this, and it looks great. I've not tried out templates yet. One thing I've noticed is that if I use it to search for a note, or do a task search, and then press command and enter on the desired note ( say '202006181843 Test Note', it does a search on the title ('Test Note') rather than on the UID and therefore acts more as a filter. Have I missed something in the set up?

• edited June 2020

You can change the use_zettel_id_in_title option to include the Zettel ID in the title. However, that option was mainly intended for when you create a new note from a template (as when that option is disabled, the {title} placeholder will not include the Zettel ID and you can use the {zettel_id} placeholder for that elsewhere in the note).

I can update the workflow to match the complete filename in The Archive instead of just the title, OR alternatively, I can add an option which lets you match on the Zettel ID instead of the title.

Not sure which is best, what do you think?

• @pryley said:
You can change the use_zettel_id_in_title option to include the Zettel ID in the title.

Thank @pryley, I'll take a look - I've not played with it enough to find the settings, so huge apologies for asking you questions before I do. I've never used Alfred before, so I'll get my head around it and look at the options you mentioned. I really like the to do toggle, that could really enhance my workflow.

• @GBC @pryley Ack! I've got KM and have just figured out basic usage. A friend keeps telling me I should check out Alfred. I guess that's another "next step". Good suggestions above.

I only generate one or two notes a day (right now; maybe more in the future) so I'm not sure how useful these various automation macros will be. But I can see how they would be important to someone with a busy workflow.

• @GeoEng51 I'm looking to automate it so I can use less brain power 😂

• You can do this in KM. You will use KM to do the keystrokes for you, basically. The steps involved:

1. Set the macro to activate in "The Archive" only
2. Set a trigger, e.g. a shortcut
3. Create the note with the content:
1. Make KM perform ⌘N to create a new note
2. Make KM "Insert Text by Pasting", and there you can add your template info
4. Optionally, rename the note
1. Make KM perform ⌘R to start renaming the note
2. Make KM "Insert Text by Pasting" to insert the note title according to your template

If you're feeling fancy, you can also create a new file in your Zettelkasten directly. That's more straightforward (create file with name X and content Y), but bit more intricate to set up if you're not comfortable with the scripting. As a last step, show the note in The Archive: either make KM activate the app "The Archive", make KM perform ⌘L and insert the filename as text to navigate to the file, or execute the URL scheme thearchive://match/FILENAME-HERE

Author at Zettelkasten.de • https://christiantietze.de/

• @ctietze said:
You can do this in KM. You will use KM to do the keystrokes for you, basically. The steps involved:

>

Ah, brill, I'd not thought about the renaming function - much better than my hack.

Definitely not comfortable with scripting but so tempted to learn. Any tips as to the best scripting language to start with?

• For reasons unknown, the ⌘R method was super unreliable, working fine at times and refusing to rename the note at others. I've used a ⌘L approach to create the required title in the omnibar then press enter to create the note. But I'm pretty close to what I need for now, thanks @ctietze.

I'm still going to check out Alfred as this offers different templates that might suit the way I work.

• Let me show you how I create new zettels using Keyboard Maestro.
I use 2 Keyboard Maestro macros to create new Zettels and a template. My template is kept in Keyboard Maestro but doesn't have to be.
Here are the macros are in a bundle.

The first (Create Note), consists of a HotKey followed by a prompt for a Title then it grabs the "Template" and creates the Zettel. I placed the macro in the "Global" group in Keyboard Maestro so it is available when I'm in any application. This is for sudden inspiration.

Here's a demo. It starts in Evernote, I see a quote I want to capture and work with. I copy the quote, execute the macro, a new note is created, I paste in the quote, make it a blockquote. I did much more work of camera to massage the note until I liked it and captured what I felt its mean for me was.

The second (New Structure Zettel), takes highlighted text and converts that text to a title and then replaces the text as a link in the format of [[202006170849]] Aerospace GIS. This is used when creating a structure note. My goal is to have every note tied to another note - usually a structure note. So I pull up a structure note, start a new entry. (without concern about the form) and then highlight relevant text for the title and using this macro a link is created and a new Zettel is created starting a refactoring of the notes

This is harder to demonstrate.
Here's a demo. It starts with a structure note, as I add a new entry I start adding it like in outlining. Adding detail as it occurs. I notice that I'm getting a single atomic idea and want to get it off on its own note. I cut the text and highlight the relevant title text and execute the macro. It creates a note where I paste in the text in and continue with the work of integration and refactoring.

Currently, I use one template (Template), but this could easily be expanded to use a couple of templates. This macro has no trigger as it is called by the other two macros.

Will Simpson
“Read Poetry, Listen to Good Music, and Get Exercise”
kestrelcreek.com

• @Will These are great, thank you. I think I've got the last one covered by one I grabbed from here which is something like 'make new zettel from existing text', if I've understood what your macro is doing correctly - but yes, you've made me stop and think whether I need a completely new note from scratch or whether in reality I'll be linking from an existing one. That would be a much better practice, of course...

• @pryley said:
You can change the use_zettel_id_in_title option to include the Zettel ID in the title.

Hi, this setting doesn't seem to make any difference, but I've noticed that either setting works to open the right note in the external editor rather than TA, which is a workaround. It would be great to be able to look at the tasks and just resulting note, though, if you can think of a way of doing that?

• edited June 2020

@GBC said:
For reasons unknown, the ⌘R method was super unreliable, working fine at times and refusing to rename the note at others. I've used a ⌘L approach to create the required title in the omnibar then press enter to create the note. But I'm pretty close to what I need for now, thanks @ctietze.

Often issues with KM macros involving a series of steps—especially ones that use an application’s shortcuts—stem from timing.

In the workflow described by @ctietze, one could add pauses between each step using this action:
https://wiki.keyboardmaestro.com/action/Pause

“Pause” is the secret sauce that makes many KM macros work.

• Thanks @dave, I did wonder if that were the case and added a pause between the steps that seemed to be failing, but found the same issue. I've put it to one side for now, as it's easy to get carried away by such things and burn up time that could be used reading and thinking.

• @GBC, gotcha. I guess the secret sauce can't fix everything.

• @dave said:
@GBC, gotcha. I guess the secret sauce can't fix everything.

I suspect, as an enthusiastic amateur, I inadvertently kill a lot of secret sauce for reasons unknown... 😂😂

• @Will said:
Let me show you how I create new zettels using Keyboard Maestro.
I use 2 Keyboard Maestro macros to create new Zettels and a template. My template is kept in Keyboard Maestro but doesn't have to be.

Will - this is very helpful - thank you! Excellent example of how automation of a task can actually improve productivity, but done elegantly as well.

• @GBC And thank you for getting this thread going. Most helpful discussion, reading through everyone's questions and comments.

• edited June 2020

Hi, this setting doesn't seem to make any difference, but I've noticed that either setting works to open the right note in the external editor rather than TA, which is a workaround. It would be great to be able to look at the tasks and just resulting note, though, if you can think of a way of doing that?

@GBC

Ah, sorry. I forgot that I added the "prefer_filename_to_title" option in v1.1.0

Use the prefer_filename_to_title option. This option determines whether to match the note in The Archive using the actual filename or the note title (in the form of "# Title"). Change this option to True and it should fix the problem.

You can press Shift on any of the options and it will Quickview a help file which explains what the option does:

• @pryley Hi, apologies if I'm being a pain but is there any other settings in Alfred that need to be addressed? I downloaded it specifically for your workflow, so have no experience of it otherwise. Making that change hasn't made a difference,

• edited June 2020

@GBG The True and False values are case sensitive in python so you will need to make sure you set the value as True (uppercase T). I will update the workflow shortly to remove this restriction.

Also, please make sure you are using the latest version. I intend to rewrite some of the workflow in order that it can self-update (as the current implementation is not working). For now though, to update it you will need to manually download the latest release and double-click it to update.

You can type arhelp in Alfred to open the readme file in your Markdown editor, the link to download the latest release is in the “Installation” section of the readme.

• Sorry for commenting on an older thread but I'm looking for a bit of help automating a specific task. I want to create new notes for every new tag. I figured out how to create files from tags and update their filenames using a shell script (based off of @Will's insert tags and tag cloud generation macros), but it does this for all tags, each time the macros is run. I need to figure out how to create new files only for new tags. Has anyone here been able to implement this so far?

• @mtl_zack I'm confused??
What is the workflow you are trying to automate?

It sounds like:
1. You have a Zettelkasten with some notes and some of those notes have tags.
2. Do you get an idea for a new tag and what to create it first then the note??

Seems like I don't understand. This is backward to my workflow but it could be automated with Keyboard Maestro. Have the creation of a tag launch the creation of a note.

Will Simpson
“Read Poetry, Listen to Good Music, and Get Exercise”
kestrelcreek.com

• @Will said:
Have the creation of a tag launch the creation of a note.

This is exactly it. I want to have a note for each tag, so that I can expand upon its actual meaning, rather than just rely on the 1-2 words that make up the tag itself. The tag would essentially be the title, along with a UID (matching the time when the tag was first used, though there might be conflicts if it matches the minute of the note it was first used in. I could resolve this my using more granular timestamps as UIDs).

• @mtl_zack said:

@Will said:
Have the creation of a tag launch the creation of a note.

This is exactly it. I want to have a note for each tag, so that I can expand upon its actual meaning, rather than just rely on the 1-2 words that make up the tag itself. The tag would essentially be the title, along with a UID (matching the time when the tag was first used, though there might be conflicts if it matches the minute of the note it was first used in. I could resolve this my using more granular timestamps as UIDs).

Would using straightforward links to the 'meaning' page instead of tags give you the same benefits?

• @GBC said:

@mtl_zack said:

@Will said:
Have the creation of a tag launch the creation of a note.

This is exactly it. I want to have a note for each tag, so that I can expand upon its actual meaning, rather than just rely on the 1-2 words that make up the tag itself. The tag would essentially be the title, along with a UID (matching the time when the tag was first used, though there might be conflicts if it matches the minute of the note it was first used in. I could resolve this my using more granular timestamps as UIDs).

Would using straightforward links to the 'meaning' page instead of tags give you the same benefits?

Yes, essentially. I guess it would be prudent to also assign by default a prefix to the tag/meaning page so that it appears at the top of The Archive's search results.

• @mtl_zack, I get it now. You want a note that explains each tag as you create the tag.

I assume you are using Keyboard Maestro? I've attached a pair of macros that might help.
The second macro is just a template of the final note. Edit to your liking.
The first is where the action is.
1. Be sure you put this in your The Archive Group.
2. Be sure to set the trigger (currently set to ⇧F12 and available in the Status Menu.)
3. The workflow is such that immediately after you create a tag you execute the macro as the mouse cursor must be directly behind the tag. This GIF shows this in action.

1. You can modify the naming convention of the note that describes the tag.
2. Timing for the UID might collide with the previous note but I think this would be a rarity. If you were worried, maybe the UID could be set to last year like this %ICUDateTimeMinus%1%Year%yyyyMMddHHmm%. This would have the added benefit of sorting all these Tag Detail notes at the bottom of the Note List.

Let me know if this is helpful.

Tag Details Macro

Will Simpson
“Read Poetry, Listen to Good Music, and Get Exercise”
kestrelcreek.com

• Thank you WIll! I will test it out over the next few days. Although I haven't started using it yet, I'm wondering if it would detect whether a note for the tag already exists, so that it does not overwrite existing notes.

• edited August 2020

No, this macro will NOT check to see if a tag has already been used to create a 'tag detail' note. I think this is a critical step that I failed to include. I'm looking at this but it is surprisingly confusing and difficult for me to grasp the logic to make this happen with the tools of Keyboard Maestro.

This macro will not overwrite a note, instead, it will create a second or third note. This is one of the safety features of using a UID in the name of the file.

This shouldn't keep you from trying the macro. I'd appreciate any feedback on how it works for you as I work on this detail. I'll keep you posted as I make progress.

Will Simpson
“Read Poetry, Listen to Good Music, and Get Exercise”
kestrelcreek.com