Replace the title with the selected text in a note

How to replace the title with the selected text in a note ?

is there any plugin available ? or any tricks to do this ?

copying the text and then go up and select title and then paste it is driving me crazy.

This sounds like a task for Templater. Use its tp.file.selection() to get the selected text, and if you got something feed that to await tp.file.rename(). Assign a hotkey to tis template, and you’re done.

1 Like

Thank you for your reply,

i tried this

<%*tp.file.selection() %>
<%*await tp.file.rename() %>

and it gives me a parsing error…

You need to use the tp.file.selection as the new name. So you can write like this:

<% await tp.file.rename(tp.file.selection()) %>
1 Like

Thank you,

the script you provided did change the title,


it also removed the selected text …

i don’t want to remove the selected text

Try the following then:

const newName = tp.file.selection()
if (newName) 
   await tp.file.rename(newName)

tR += newName

This version should re-insert the selection, and only try to rename if you actually have something selected.

plugin:templater-obsidian:61 Templater Error: Template parsing error, aborting.
Template syntax error: Unexpected token ‘const’

got the above error

I forgot to do <%*. Update accordingly…

1 Like

Thank You @holroy and @Anwen , Finally it worked …

const newName = tp.file.selection();
if (newName) {
   await tp.file.rename(newName);
   tR += newName;

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