jviotti
jviotti

Reputation: 18939

Vim mappings depending on keyboard layout

Is there a way to do certain mappings for specific keyboard layouts?

For example:

if iskeyboard('es')
  let mapleader = ","
endif

Does vim support this?

Upvotes: 2

Views: 363

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172768

Vim doesn't know anything about the keyboard layout, it just receives a stream of keypresses. That mapping falls into the responsibility of your operating system (which translates the raw, physical keypresses reported by the keyboard driver into logical keys).

Therefore, any solution depends on querying the current layout from the operating system. Vim can interact with it via:let output = system({command}). The actual {command} depends on the operating system; here is an answer for Linux. If that's too complex, maybe you can check the current language ($LANG on Linux), or a special environment variable that you set for each system (assuming the layout is fixed for each system).

Upvotes: 4

Related Questions