-
-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tp.file.cursor(1) not working #397
Comments
Hey @Lorena1908, the automatic cursor jump is now disabled by default. You can enable it back in the settings of Templater. |
Thank you for the great extension @SilentVoid13 ! That the automatic cursor jump needs to be enabled separately might be something worth mentioning in the docs. Being new to the extension, it puzzled me greatly that omitting the |
well, it's ok for it to be configurable, but I think it's really not a good idea to add a setting with the default opposite of the current behaviour. and a dozen bug reports for the same issue is an obvious result. |
It was confusing to me that it looks like it doesn't parse the entire code block. (eg: it prints the text of suggest instead to:
|
Whether it was broken before or not, it's definitely broken now for me using latest stable versions of plugin (1.12.0) and Obsidian (0.15.9) on Mac. Double-checked that I still have the setting set to on, but it's just showing the string and not replacing it. Please fix! |
It defaults to file name now |
Can confirm defaulting to file name for me after update to 1.14.1 for me this morning. Hope there is a fix for it |
Obsidian's default behaviour has changed which is why this command no longer works as expected. |
This is not working in v0.15.9, the hotkey "Templater: Jump to next cursor location" IS WORKING but not the automatic jump. |
It costs me half an hour to figgle around and find this. For me <% tp.file.cursor(1) %> does not work at all, but I'm new with templater. I need a precise guide (preferable in the docs). |
Sorry to hear. It's still broken last I checked and it'll be a while before it gets fixed. If anyone wants to take a stab at it, I'm happy to guide them! |
Also happy to merge a warning in the docs that this isn't working as expected right now. |
came here to say this. exact same situation |
just to add that it does work when the note is created with templaters own my template
|
For me, it's become work after I switched on the toggle "Automatic jump to cursor" in the plugin settings. Thanks, @apricot13 for the screenshot. Now the plugin behaves next way:
Not very pretty, however, works. Better than nothing. |
It does not work at all for me even with all the mentioned settings activated and the newest version of the plugin and Obsidian 1.1.9. The cursor always stays at the start of the file in front of the file name, the line with tp.file.cursor(0) is highlighted and tp.file.cursor(1) is not replaced at all, but I can jump to it using the hotkey and it is replaced then. |
@gsommer I think that is the intended behaviour. From the documentation:
|
But the actual cursor is not at cursor(0), so that I can start entering text there. It is at the beginning of the first line of the file. The line where I positioned cursor(0) is highlighted, but when I start entering text it is entered at the beginning of the file and not at the first cursor position. There is not any usefulness in this. If I cannot define the position where I want to enter text after the template has been expanded, what is the point of having a cursor? |
@gsommer Oh I see. I thought the tp.file.cursor(0) was replaced and the cursor was it its place and it was just cursor(1) that was not replaced. Questions:
Thanks Edit: I tried all the different ways that one could use Templater to use |
The file is generated with "New Note". Yes, if I press enter the curser jumps to the first cursor position. The second cursor shows as <% tp.file.corsor(1) %> until I press the hotkey. With the Insert Modal the cursor is at the right place after inserting, but this is not how I want to open a note. Anyway it is an acceptable workaround for now. Thank you. I don't like that the templater source code shows after creating the note. But I guess there is no other way to do this. |
Although tp.file.cursor is not working the way you are hoping for, I am glad to hear that it is working as intended by the developer as described in the manual. Maybe we will see changes to how it works in the future. |
Still not working. Obsidian 1.1.16, Templater 1.16.0. "Template parsing error, aborting." Using Templater insert mode. Both command-p and "insert modal". |
I discovered this is caused by the editor option Advanced / Auto convert HTML. When I turn that off, exit settings, then turn it back on, the cursor positions as expected without displaying the |
I'm finding that |
@fredcallaway pics/gif or it didn't happen XD |
Ack sorry I figured it and forgot to report back. When I saw the |
IMHO, this should be mentioned in the documentation. I am a software engineer, and even I needed clarification on this. |
This doesn't work when we insert a template from the sidebar. I believe this is because the active context is no more the editor. It works fine when we add a shortcut and keep the cursor in the editor. The sidebar template selection should fix the |
What I noticed is that it works for me, but Obsidian now defaults to putting the cursor on the document title by highlighting the title. All I need to do now is hit "Tab" and it jumps to where it should be. Potential solution Template
will be rendered as
Hit "tab" and:
|
FYI multiple cursors is the expected behavior:
|
Ok, I have to admit that this was being very confusing to me. I was expecting for all the appearances to be replaced with a space or subtle placeholder, and then to be able to jump to them with just tab. Seeing the template "unexpanded" made me thought it was not working. On a sidenote, is there a way to use just tab, and if there is no place to jump, execute the normal tab in obsidian? |
I'm also getting this exact same behaviour. It was working fine until I added some code in my template to prompt for the title name of the new page and then rename. That part works as intended, but now instead of jumping to |
This doesn't work for me at all, I think I tried all possible combinations already What I tried: Confirmed that the setting is enabled, that templater works (the "hello" message does show up), ensure the command is triggered from templater and not the core templates What happens in all cases is that the cursor command line doesn't show up, and the cursor never jumps to that line, not even when triggering the jump cursor command. Obsidian 1.3.7, templater 1.16.0 ps: I'm new to templater, so it's possible I'm missing something very basic, please let me know! |
The following works without problems:
Code: ## Why
<% tp.file.cursor(1) %>
## How
<% tp.file.cursor(2) %>
## What
<% tp.file.cursor(3) %> |
@sanjarcode I'm unsure if your reply was to my previous message, but if it was, it unfortunately doesn't work for me. What does seem to work is inserting the template through the core templates command, and then pressing "option + Tab" (not templateR, which means the template code is visible, exactly like the first part of the image I shared above). That makes the cursor work, but nothing else in the templater code does. If I insert the template with templateR, then I get the image on the right. Templater executes, no template code, but cursor simply at the end of the file (and pressing "option + Tab" does nothing). A video might be easier to understand what I mean: Screen.Recording.2023-09-10.at.3.35.50.PM.mov |
It helped me with the same problem: <% tp.file.cursor() %><%* app.workspace.activeLeaf.view.editor?.focus(); %> |
Anyone succeeded in having the cursor placed directly where Obsidian default behavior upon new note creation is to focus the title, and you only have to press tab/enter once to get to the cursor, but this defeats the whole purpose of |
Plugin informations (please complete the following information):
Describe the bug
When I insert a template that has
<%tp.file.cursor(1)%>
, this is not replaced by the cursorExpected behavior
This code should be replaced by the cursor
Screenshots
Here is a screen recording
Obsidian.-.Obsidian.v0.12.15.2021-10-03.19-51-48.mp4
Extra information:
I noticed this happened because of the latest version: 1.9.9, because when I downgraded to the previous version (1.9.8) it worked properly.
The text was updated successfully, but these errors were encountered: