How to create new file using code snippet or script?

Hi, is it possible to create script that will create the new .md file in a specified location with specified content? I looked through several plugins. Seems like they can do the job, but I cant find the right plugin or combination of plugins for the job and need some code example.

I want to add “comment feature” to md file
1.md:

some content
...

--comment Here is my comment!-- (here I typing my snippet "comment")

This should produce
1.md:

some content
...

##### commentX
![[commentX.md]]

and should create new file commentX.md
commentX.md:

Here is my comment!

source: [[1.md#commentX]]

This is what the core Template plugin or the community plugin Templater are for.
The latter is good for more advanced stuff that can move the note about to be created to a specified folder.
There are tons of stuff about it on the forum. You can browse also here:
SilentVoid13/Templater · Discussions · GitHub

1 Like

Thanks, i tried it with tp.file - that’s exactly what needed.

Can u suggest the way, how to create snippet to run this code? Templater and hotkeys for templates support only hotkeys, and I want something notion-like, so I would type like /comment, hit enter or smth and this text transforms into template

When you have a template, you can trigger it by other means than hotkeys (I don’t like to do that either).
May I suggest watching this guide on how to incorporate various templates into a so-called meta-templater?

  • This is what I used to start out with and learn a little about Templater js.
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.