ultisnips
ultisnips copied to clipboard
Expand snippets if only partial prefix of the trigger word is typed
I would like to write snippets that can be expanded after typing only a part of the trigger word. For example, i
, im
, imp
, impo
, impor
should all expand to import
when followed by the trigger key, e.g. Tab. This is helpful because one may think of a snippet after having already typed a couple of characters of a code construct. At the moment, this is possible through somewhat complicated regexes, making it hard to define such snippets. Is this supported in an easier way? If not, would it make sense to add a snippet option for this?
Nevermind, I found #268. You're mentioning completers that are better suited for this use case. Which ones were you thinking of? By the way, I think it would be perfectly fine if this didn't work for regex triggers if it were added as a feature.
As you noted, the regex for this would be rough: i(?:m(?:p(?:o(?:r(?:t?)?)?))?)?
Personally I would also love the feature that you're proposing and that was proposed in #268.
One popular completer is deoplete, and many people swear by it.
Thanks for sharing the regex. If this worked it should be really easy to add this feature as a snippet option to UltiSnips.
I'm using droplete but so far it seems to fill quite a different use case than triggering snippets that may include anchors for the cursor to jump to etc.
Yes, this would not be a hard feature to add. I came around to it as maybe being a good idea to implement and would love to see a patch for it.