NotePlan
NotePlan
Jan 4

Ability to set cursor position in template

When inserting a template, it would be helpful to be able to set the cursor position once the template has been inserted. I imagine a special character or command could do this. e.g, I could have a template like: ``` # {{subject}} meeting with {{people_list}} ## Notes §CURSOR§ ## Actions ``` Where `§CURSOR§` is where I want the cursor to be after I have inserted the template.
PendingPending

Jan 5, 2022

Hey Rob Here is how your template would be adjusted to use `np.Templating` ``` # <%= subject %> meeting with <%= people_list %> ## Notes <% note.setCursor() %> ## Actions ```

Jan 4, 2022

In the upcoming `np.Templating` (will be replacing the current templating interface), there is a command: ``` <% note.setCursor(line, position) %> ``` Where `line` is desired line, and `position` is vertical adjustment

Jan 4, 2022

Mike Erickson: What if u don’t know the index, you want cursor left HERE? Maybe <% note.setCursor() %>

Jan 4, 2022

David Wertheimer: If you could give me an example of what you are looking for, I am sure `setCursor` method will do what you want. But if it is not possible yet, I will make it possible before `np.Templating` is released.

Jan 4, 2022

Mike Erickson: What I think Rob is asking for is to have a tag that leaves the cursor in a certain spot when the template is finished processing. So basically a tag that says, "leave the cursor where this tag is when you're done". That's why I was thinking maybe your function <% note.setCursor() %> without any parameters could leave the cursor in that spot. I can totally relate to this request. I have a meeting template that I use all day long, and I want to immediately start typing under the Notes heading. I don't really know what the line index is for that, so I'd like to put this in my template: ## Notes <% note.setCursor() %> ...and that way, when I run this template and all the tags are processed, Noteplan (and @codedungeon) leaves me at that spot under ## Notes and I can start typing... so basically, the template code would behind-the-scenes figure out the line index and position and pass that through to Eduard's API.

Jan 4, 2022

David Wertheimer: OK, I see what you (and perhaps Rob) are requesting. I can do what you are asking, but it should be clear, that the last call to `note.setCursor()` would take precedence.

Jan 4, 2022

Mike Erickson: makes sense to me! thanks Mike.

Jan 4, 2022

Mike Erickson: Glad to hear that you’ve almost implemented this already. I second (third?) the request. FYI TextExpander has exactly this functionality, and I’ve found I needed it in the past. BTW how do you implement this? It seems to me that one of the gaps in the current API is a cursor positioning function.