Replies: 1 comment
-
Before you start optimizing, what is a lot and is this really necessary?. With that said, you can combine snippets with a prefix into 1 regex trigger and de-structure the snippet in a replacement function. This is just to optimize typing, and not to affect other snippets, idk how this will affect expansion speed. example: {trigger: /;(a|b|c)/, replacement: (match) => {
const greek = match[1];
const greekMap = {
"a": () => "\\alpha",
"b": () => "\\beta",
"c": () => "\\chi"
}
return greekMap[greek]()
}} you can check with regex101.com or other regex sites to see how many steps your regex takes and thus how fast it is. When using regex avoid recursive backtracking, like the regex |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to write many snippets to expand certain things for templator or dataview on regular typing mode, how should I write the snippet so that the time cost is minimal? I don't want obsidian to be laggy because of this.
Would having a special prefix such as < and a postfix > help? Or perhaps can we group certain prefix and post fix together, so that it's only checked once? Such as only when I type ">" something happens. In that case, when I type other characters it is O(1) of time.
Beta Was this translation helpful? Give feedback.
All reactions