Separate New Note Commands

Use case or problem

I want to create new notes with a hotkey (or button using plugins) in specific folders, primarily:

  • The same folder as current note
  • The vault root folder

Obsidian has a setting to change the default location between these two but there seems to be no way to do them both with their own hotkey.

Proposed solution

Dedicated commands:

  • “Create New Note in Same Folder”
  • “Create New Note in Vault Folder”

Current workaround (optional)

Using the open dialogue it is possible to create things in any folder, but this distracts from what I need to write to figure out where to put it and what to name it. Very often I don’t name something until after I write the content - once I have a good idea of what a fitting name might be.

Plugin: QuickAdd

The QuickAdd extension might be able to accomplish this with its templating system.

Personally I am not interested in such a large plugin for such a simple task - partially one that includes network traffic to systems I do not trust, like hosted LLMs. So unlike the other workarounds, I will not test this one myself, but other people may find it useful.

Plugin: Templater

Using templates which point to other templates it is possible to inject a bunch of code and create complex behavior, including emulating something like this.

Until I write the custom template scripts, the ones I have seen have popups and other obstacles to simply creating a note. It also by its nature runs arbitrary code while doing this. This is a very powerful tool, but it requites technical skill and may break with updates. (hopefully not, Templater is an amazing plugin!)

Plugin: Create Note in Folder

This plugin is by far the smallest and most direct route to emulating this behavior. By setting Obsidian to create note in current folder, then this plugin can create a command which creates a note in the vault folder which can then be mapped to a different hotkey.

However, if you wish orphaned links to be created in the vault folder, then this solution will not work for you.

Related feature requests (optional)

There are a ton of questions related to this, but the answers usually come back that they need to choose one or the other.

3 Likes

Using a combination of Create Note in Folder and Templater might be all that you need. You may not even need Templater if Create Note in Folder adds the ability to use the current folder as the destination for the new note. It looks like Templater by itself also supports a hotkey per template.

1 Like

Thank you for trying to help come up with workarounds.

Unfortunately, Templater’s “template hotkeys” do not create new files, they only insert a template into the current file.

I’m going to spend some time with Create Note in Folder and see what it can do. Thank you for the recommendation.

I’m unclear as to how Templater can make a new note in the current folder though? Do you have some example code you can share?

@acook this should give you everything you need to create the exact workflow you’re looking for :slight_smile:

See the Settings section for how to choose the destination folder per template.

They certainly can - the Templater script above will do exactly that.

By specifying the folder in tp.file.create_new. But again, it’s all in the above template.

2 Likes

I did mentioned QuickAdd in Current Workarounds.

There’s not a lot of info at that link and the code points to a broken obsidianshare page that was supposed to have more info, but I assume is just the same original page moved to note.sx?

That said, if I am understanding correctly, you are suggesting that by creating a proxy template which is inserted into the current note, and then that code could pull from the current note to get its parent folder and then invoke other code to create a new note in that same folder.

It seems to accomplish that with:

destinationFolder = destinationFolder || tp.file.folder(true)

It’s definitely an interesting workaround. I’ll see what I can build with it. Thank you for sharing.

Actually nothing is inserted into the current note. You can run a template without having it insert anything. The template just pops up the “Choose a new note” dialog, and then you could choose, for example:

  • Create a new note in the current folder
  • Create a new note in the vault root folder

Or anything you’d like to configure.

Thanks - fixed, but you are correct that it’s just the docs I linked to originally.

Out of interest, what should I add? The script is just copy and paste and everything should immediately work.

It’s not immediately clear what it does. At first it almost looks like the normal Templater setup and screenshots.

I think a short summary at the top would help.

After playing with it, it is neat that it lets you use templates from any subfolder and not just the generic Templater folder. I made a similar feature request to Templater recently. You could just copy the entire template and change the template directory and assign them hotkeys to have a lot of different template dialogs.

Also that it creates a link to the new note after filling the note with the chosen template. And if you don’t choose to insert the link, it will take you to the new note. Which seems like a particular thing that some people will like for their workflow.

Then there is that option at the top of the file which changes it to open a pane to the right instead of going to the page in the current tab. The opening behavior isn’t mentioned at all.

And now having spent some time looking at the functions, it seems like they could be extracted and shared between multiple templates.

While I have you here, I noticed on your site you mention “Change a single property from a template” with some code nearly identical to some I was working on today, but I find that embedded in a template when making a new file that both your version and my version delete the frontmatter after it is generated, and replace it with only what was added. Did you ever find a workaround for that?

1 Like

Thanks for the useful feedback! :+1:

Just make sure you have the timeout delay, so that the note can finish processing first, before the new additions/changes are made.

I’ve tried it with the timeout in your code as well as various other attempts at delays up to 2 seconds. It doesn’t work with new files. Thanks though!

Related request (similar problem but aimed at improving the “open file” flow; I’m just posting it to connect the 2 requests): Tab to Autocomplete path parts in Quick Switcher