Reputation: 13
I'm attempting to migrate to VSCode (from Vim) for LaTeX typesetting. I've been able to forward most of my previous preferences from Vim thanks to VSCode's extensive support of extensions, but there is one feature from the UltiSnips Vim plugin that I have not been able to match.
I would like to be able to make snippets based upon the suffix of a word, rather than it in its entirety. For example, I would like a snippet that maps t
to \text{$1}
on tab REGARDLESS of the characters that occur before t
. If the word planet
were present and my cursor was on the final t
, I want it to expand upon tab even though the entire word does not match.
Is this possible in VSCode? I have seen several posts here on StackOverflow (and on the VSCode website itself) explaining how to use regex and other tricks within the body of a snippet, but I haven't been able to find a way to do this within the prefix.
Upvotes: 1
Views: 2037
Reputation: 180885
I ran across the HyperSnips extension lately and it solves your problem. In your latex.hsnips file:
snippet t "expand t to \text{$1}" i
\text{$1}
endsnippet
Now, a t
, even within or at the end of a word can trigger the replacement value upon a Tab.
See https://stackoverflow.com/a/62562886/836330 for more info.
Upvotes: 1