Selecting words & getting text surrounding the word in "templater" possible?

Hi All,

I was wondering if it is possible in templater (or another plugin) to select text and put some specific text surrounding it.

Context: In the ANKI app its possible to select text and make it a cloze deletion which is nothing more that putting this surrounding the {{c1::TEXT}}.

Since its a but cluncky now to create & manage cloze deletion flash cards by manually adding text. I was hoping for something like this :).

Any help/feedback is welcome!

I know there’s a similar topic here, but not sure if this is what I mean. Highlight Text Surround with Template

Not sure if you still need this, especially if you may have started using the Obsidian_To_Anki plugin since your last post… I suppose this template might improve your workflow if you assign the shortcut key to your mouse :man_shrugging:t5:

<%* let clozeNum = await tp.system.prompt("Which # is this cloze"); -%>
<%* highlightedData = tp.file.selection() -%>
<%* highlightedData = "{{c" + clozeNum + "::" + highlightedData + "}}" %><% highlightedData %> <% tp.file.cursor(1) %>

The code prompts you to enter the Cloze # in case you are using multiple clozes, so you would just enter 1 or 2 or 3 or…