obsidian-latex-suite icon indicating copy to clipboard operation
obsidian-latex-suite copied to clipboard

[FR] Check regex after the cursor

Open vlad2305m opened this issue 1 year ago • 2 comments

Please add an option to check string after the cursor with a regex before applying the snippet, and optionally modify it Ex: { trigger:"{", replacement:"{$0}$1" , after:"[^a-zA-Z]", options:"Am"} would not open a bracket if directly before a word, and {trigger: "lr\\[", after:"(\\])", replacement: "\\left[ $0 \\right[[a0]] $1", options: "rmC"}, will get rid of the annoying automatic second bracket.

vlad2305m avatar Nov 07 '22 08:11 vlad2305m

You can add the "w" word boundary option to the snippet so brackets are not opened directly before a word.

Could you clarify what you expect the behaviour of the

{trigger: "lr\\[", after:"(\\])", replacement: "\\left[ $0 \\right[[a0]] $1", options: "rmC"},

snippet to be?

artisticat1 avatar Nov 19 '22 15:11 artisticat1

It would expand lr[ text only if the closing bracket is present after cursor. Closing bracket is also captured by the group and substituted into [[a0]] like with groups captured before cursor.

vlad2305m avatar Jan 23 '23 21:01 vlad2305m