Templater: rename file & focus on its content

What I’m trying to do

I’m trying to automatically assign a name of format note ${num} to every new note created in the “notes” folder, after which I want the cursor to focus at the beginning of the file content.

Things I have tried

I’ve created the following “note” template:

<%*
const noteFiles = this.app.vault.getAllLoadedFiles()
  .filter(f => f.parent && f.parent.path === 'notes');
const noteNum = noteFiles.length;

await tp.file.rename(`note ${noteNum || 1}`);
-%>

<% tp.file.cursor(0) %>

But the problem is, with or without the cursor line, the cursor stays focused on the title until I hit the down key twice. Is there a way to focus within file content automatically after renaming the file?

P.S. I have the “Trigger Templater on new file creation” option enabled.

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