Snippet that replace the whole text

Asked by Juan José

Hi, first of all this plugin is great.
I do not have any idea of python, so I wonder if anybody could help me with this.

For me it is easy to write words with the keyboards, although writting numbers and simbols is different...
I would like to make a snippit like this:

You write the snippet tab trigger n
and now you write a mathematical expresion, but with letters, for example:
ob ontwthfofisiseeini cb di fo pl si ti on

where each 2 letters represetn a number or a symbol
on = 1
tw = 2
th = 3

ob = open brace (
cb = close brace )
di = /
pl = +

etc...

or it could be done with a differten mapping...
I ve do it with transformations, but the problem is that the first input remains

so you tipe n tab, and enter
ob ontwthfofisiseeini cb di fo pl si ti on

and you obtain

ob ontwthfofisiseeini cb di fo pl si ti on
( 123456789 ) / 4 + 6 * 1

How could I delet the first input and end only with the math

Thank you

Question information

Language:
English Edit question
Status:
Solved
For:
UltiSnips Edit question
Assignee:
No assignee Edit question
Solved by:
SirVer
Solved:
Last query:
Last reply:
Revision history for this message
SirVer (sirver) said :
#1

:help imap ? A snippet seems overkill. Ultisnips does not support automatic triggering after every keystroke.

Try
:inoremap on 1

And see if this is what you want.

Revision history for this message
Juan José (blascoburguillos) said :
#2

It may work, but I do not want every "on" that i write to be replaced. Could I trigger the imaps with a key? so only when I activate this 'number mode' theese imaps have effect?

Thank you

Revision history for this message
Best SirVer (sirver) said :
#3

Listen, either eat the frog and use on<tab> and make a regular inword snippet for this or write yourself a vim function that sets and resets imap's for your use case. The first solution is trivial with UltiSnips - read the docs about inword triggers, the second is out of scope for UltiSnips - I will not help you with this, as I cannot help everybody with every Vim question. Try your luck on stack overflow.

Revision history for this message
Juan José (blascoburguillos) said :
#4

Thanks SirVer, that solved my question.