3

I use gVim and UltiSnips because it helps going way faster to type maths in LaTeX. To do so, I use a lot of snippets which expand automatically, for instance:

snippet ( "" iA
\left(
endsnippet

The problem is that, when I type too fast, some snippets do not expand automatically. The easiest way I found to reproduce this is to simply hold the "(" key using the snippet above. After some time, I start seeing things like "\left((\left(", whereas it should be "\left(\left(\left(". I found that when the line I am writing is very small, this problem does not occur often, but the longer the line the more I see it. I have also noticed that the size of the document I am writing and the number of my snippets are other factors which make this problem worse.

All this makes me think that UltiSnips takes too much time to process a key press, and then, when it looks at what was typed since the last update, it skips (voluntarily or not) some key presses. I don't really care if what is on my screen is not exactly up to date with everything I type, as long as, in the end, all text is here and all my snippets are expanded correctly (especially for the ones which should be automatically expanded).

I think that a key buffer could solve my problem. It didn't feel so when I browsed on the internet and through UltiSnips's documentation, but could there be an option in UltiSnips which I am missing? Do you think that I could use a Vim plugin or an external application which would record all my keypresses in a buffer, and give them to UltiSnips or Vim with a minimum time between two key presses? If you have any other idea or suggestion that comes to your mind, I would gladly hear it (well, read I guess) :).

2
  • 1
    Wecome to Vim :-). I'm afraid you should report that problem to the plugin author. Aug 27, 2022 at 20:56
  • 1
    Thank you! I'll follow your advice, I guess you're probably right; I'll add follow-ups here. Although, if you have any proposition concerning the key buffer I mentionned, I would still gladly read them. Aug 28, 2022 at 9:14

1 Answer 1

1

Well, it has been ten months and I have not received any answers in my GitHub issue, so I guess I won't receive any in the future. I found some very unsatisfying solution, but I'll put it here if someone has the same problem.

As stated above, my main problem takes place when too many snippets have to be triggered in a too short amount of time. My solution was thus to make sure this never happens, by using longer trigger expressions, and bigger snippets. For instance, instead of having a snippet for both ( and ), I instead use one triggering when I write asd, which writes both parentheses directly:

snippet asd "" iA
\left($1\right)
endsnippet

This is very unsatisfying, but I really could not find anything better. I hope this will help some people.

3
  • 1
    Thanks Joachim for the followup :-) Jun 25 at 19:19
  • 1
    @Vivian (This is probably not the place to write it, though there is no private messages, so heck I'll put this anyway.) Thank you so much for being so nice and going at the opposite of the stereotypical StackOverflow/StackExchange user! :) Jun 26 at 21:21
  • We are a small community. Every contribution has a lot of value! Welcome to Vim :-) Jun 27 at 3:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.