Skip to content
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

[Feature Request] Add Multiple cursor position #54

Open
Archie-2021 opened this issue Oct 5, 2022 · 9 comments
Open

[Feature Request] Add Multiple cursor position #54

Archie-2021 opened this issue Oct 5, 2022 · 9 comments

Comments

@Archie-2021
Copy link

It would be awesome if you add multiple Cursor position to jump to not just one end one.

Just found your Plugin, Thank you for this, really helpful

@jeansordes
Copy link

jeansordes commented Nov 2, 2022

Can you give an exemple ? I'm not sure to see what you mean

@Archie-2021
Copy link
Author

Right now there is only one jump point, like you put $end$ somewhere in the snippet, run it and it jumps into that location. But what if I want to jump to nextplace after that? Like how other snippet /template stuff work. Like in there is <% tp.file.cursor() %> in templater and which jumps to 1 at the launch of snippet and then we can jump to 2 and 3 ... with a press of a hotkey.

@jeansordes
Copy link

Can you give an exemple though ?

Your explanation was already clear enough in the first place, but I don't see any practical case where you would need multiple cursors, that's why I was curious to see if you had a concrete exemple in mind

@jeansordes
Copy link

jeansordes commented Nov 2, 2022

I think I found an exemple, correct me if I'm wrong

hello : Hello $1:name$,$nl$how is $2:name$ doing ? $end$

And when you call it, your cursor would go to the first cursor, with the text "name" selected, so that when you type, it will replace it with what you want, and when you hit tab it will go to the next cursor place, and do the same things, and when you hit tab again, it goes to the $end$ place

By looking at the documentation of VSCode I think I understand better how it is useful to have multiple cursors, but when I look at how the current Obsidian Snippet plugin works, it would be very challenging to implement it :/

@Archie-2021
Copy link
Author

Yeah that is a good example. It is very standard in most snippet programs I have seen, like Templater in obsidian or UltiSnips in vim. Altho tbh, I don't have a use case right now, I use Templater to fill forms and such and not got used to fully implement this plugin beside some limited cases which text expansion is much faster.

So it is a nice thing to have but not urgent and I understand that is not easy to implement technically.

Thank you.

@jeansordes
Copy link

… I just discovered that what you described was already implemented in the plugin. I feel so dumb.

See $tb$

So if I rewrite the exemple I gave but with the syntax of the plugin, it goes like this :

hello : Hello $tb$,$nl$how is $tb$ doing ? $tb$

It will replace $tb$ with $tb$, and when you'll hit Tab, it will jump to the next $tb$, so that you can type what you want.

And, just in case, the documentation says that you should not combine it with $end$
But other than that, it works pretty well actually ( >ᴗ<)

Sorry for telling you that it was not possible 😬

@Archie-2021
Copy link
Author

I am trying to test it with the example you used above but using tab key even in sandbox vault causes the whole line to indent instead of jumping to the next position. Do you know how to fix that?

@jeansordes
Copy link

Ah, you have the same problem than others

I've described a solution for that in the following comment :
#47 (comment)

@Archie-2021
Copy link
Author

Ah, you have the same problem than others

I've described a solution for that in the following comment : #47 (comment)

Thank for the help, hope the author soon accept the your pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants