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?

user4035
  • 1,039
  • 11
  • 24
  • It's an open FR (from 2011!): https://github.com/joaotavora/yasnippet/issues/114 there's also this for regex support https://github.com/joaotavora/yasnippet/issues/988 – C4ffeine Add1ct Dec 30 '21 at 22:26

1 Answers1

0

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;
Phil Hudson
  • 1,651
  • 10
  • 13