Templater: how to update file title after renaming the note title from "untitled" to something else for the first time

I am using a hotkey to create a new note from a template with the help of templater plugin. Let’s say one of the variables in the template is <%tp.file.title%>. But when I do that without creating the new note first manually, the templater populates the note with “untitled” because that is the default new note title. So even if I retitle my note, which I would be doing for the first time since it is a brand new note, the templater-populated note would continue to show “untitled” as the note title in the note.

Is there a way I get a chance to title the note and the templater can then update the tp.file.title in the note itself after I have updated the title? Without it, it kinda defeats the purpose partially to have the templater populate the field.title.

In other words, this is my desired workflow:

  1. Create a new note using the template from the templater plugin with the help of a hotkey.
  2. Now title the note manually
  3. Then press some key so that the templater updates any <%tp.file.title%> variables inside the note to the new title.

Either the above workflow or the templater itself giving me a pop up box to name the note title when #1 is run. That’d work too.

Is any of the above possible and can a non-tech savvy person like me do it?

1 Like

Probably what you want…

2 Likes

This is really good solution. I was able to get the prompt. But it created several unneeded characters or code syntax characters. I am guessing it is because I have not spaced the syntax properly. I just did a direct copy and paste and then tried to break the lines. I am wondering if there is some kind of documentation that helps with proper spacing for code syntax. Maybe this is asking for too much, and that I should invest time to figure it out. If so, then don’t worry. I can probably work this for now cutting it down to bare bones. But if you or anyone can throw a bone, that’d be fantastic.

Not sure this is the issue… As I didn’t set it up to test, but I copied and pasted like you, and I noticed that there were a couple “folds” inserted - the little white arrows.

I backspaced the lines related to those to folds back to the previous line then entered again to restore the line on its own. This got rid of the folds. Probably a special character.

The original solver of the other thread might be able to help more, I just knew I had seen someone ask a similar question.

1 Like

Does the tp.file.cursor() resolve properly in your case?

There is a plugin that does exactly what you are looking for, called Filename Heading Sync.

1 Like

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