2

Suppose we have a snippet for sql mode:

# -*- mode: snippet -*-
# name: select *
# key: sel
# --
SELECT ${1:*} FROM $2;

Sometimes I forget to switch the keyboard layout and type Russian "ыуд" instead of "sel". I tried this:

# -*- mode: snippet -*-
# name: select *
# key: sel
# key: ыуд
# --
SELECT ${1:*} FROM $2;

Here ыуд works, but sel doesn't. Is creating a second yasnippet with different key the only possibility to fix the issue? Or there is a way to bind the snippet to several keys?

Also is it possible to switch the keyboard layout when ыуд snippet is activated? Maybe, we'll need to make call to the operating system?

1

1 Answer 1

1

You need to create two snippets with different names and different trigger keys but the same expansion.

So name the first one (for example) 'sel':

# -*- mode: snippet -*-
# name: sel
# key: sel
# --
SELECT ${1:*} FROM $2;

and the second one 'ыуд':

# -*- mode: snippet -*-
# name: ыуд
# key: ыуд
# --
SELECT ${1:*} FROM $2;
2
  • 1
    This answer would be more helpful if it were elaborated a bit - perhaps with an example.
    – Drew
    Commented Dec 28, 2021 at 21:21
  • You're right, of course. I'll come back and do it when I have time. Commented Dec 29, 2021 at 23:49

Your Answer

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

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