joeyuping / quick_latex_obsidian

MIT License
327 stars 21 forks source link

Feature Request: Shorthand custom cursor location #44

Closed mayurankv closed 2 years ago

mayurankv commented 2 years ago

This is possibly similar to a feature request for shorthands to have whitespace included but for my use-case at least, there is a significant difference so I thought it best to open a separate request. Would it be possible to have shorthands expand to a custom location rather than the last set of curly brackets? \sqrt{} places the cursor inside the brackets as intended and desired but for functions with multiple inputs (some self-defined), the behaviour doesn't quite work as I would think is optimal. For example bin:\binom{}{} expands to put the cursor in the latter brackets when I would ideally want it in the first pair of brackets. Similarly, if i expand binr:\binom{}{r}, the cursor goes to the end of the expression after '{r}' rather than the empty pair of curly brackets. Ideally it would land in the first pair of brackets to begin with.

Would it be possible to implement some form of anchor at which the cursor would end at? Until your shorthand feature came to be and got fleshed out, I was using a plugin called text snippets to expand maths expressions. This had a similar functionality as to what I am describing here which could possibly be useful. (The plugin is here: https://github.com/ArianaKhit/text-snippets-obsidian)

(A little bit of an aside but the way this plugin also implements expansions appears to be similar to yours on the ui side but it has a multiline input for expansions which makes it much easier to search through! Making the shorthand list similar to this could make it easier to edit and change shorthands.)

Again thank you for any help and thank you so much for working on this plugin!

joeyuping commented 2 years ago

Thank you so much for the great suggestion!

let me see how I can implement this too

joeyuping commented 2 years ago

Resolved in v2.3.0, please update and take a look! (try uninstall and reinstall the plugin to see the new default list of shorthands)