Vim 基于关键位置的绑定
Vim Bindings Based on Key Position
是否可以让 Vim 通过实际的键位置而不是字母或符号来识别绑定?我从英语切换布局 — 不能使用任何键绑定。
假设我已将布局切换为俄语,并且我希望 Ш 表现得像 I.
位置键码称为扫描码,在硬件和低级系统软件中使用和处理。您无法在便携式应用程序中对它们执行任何操作。
原则上,也可以反其道而行之,将Russian/Cyrillic个字母映射到相应的普通模式命令,如nnoremap ш i
等。但是,这没有多大意义。
重点是 Vim 已经在 insert/replace 模式下内置了对国际键映射的支持。只需将 set keymap=russian-jcukenwin
添加到 vimrc 并在插入模式下使用 Ctrl6 即可在布局之间切换。
在正常模式下,您应该始终坚持 US/Latin。无需系统语言切换。
我用 xkblayout-state
解决了我的问题:每次打开 Vim 或通过此自动完成进入正常模式时,我只是用它切换系统语言布局:
" `0` is `en_US` in my case.
au VimEnter * silent !xkblayout-state set 0
au InsertLeave * silent !xkblayout-state set 0
我还在 Vi Stack Exchange 上找到了 this 解决方案:
To use langmap in greek you can follow the example given in :h 'langmap'
adding this line to your vimrc
(Copying this line from here may not be a good idea since I'm really not sure of the encoding, yanking the line directly from the help file is probably safer):
langmap=ΑA,ΒB,ΨC,ΔD,ΕE,ΦF,ΓG,ΗH,ΙI,ΞJ,ΚK,ΛL,ΜM,ΝN,ΟO,ΠP,QQ,ΡR,ΣS,ΤT,ΘU,ΩV,WW,ΧX,ΥY,ΖZ,αa,βb,ψc,δd,εe,φf,γg,ηh,ιi,ξj,κk,λl,μm,νn,οo,πp,qq,ρr,σs,τt,θu,ωv,ςw,χx,υy,ζz
是否可以让 Vim 通过实际的键位置而不是字母或符号来识别绑定?我从英语切换布局 — 不能使用任何键绑定。
假设我已将布局切换为俄语,并且我希望 Ш 表现得像 I.
位置键码称为扫描码,在硬件和低级系统软件中使用和处理。您无法在便携式应用程序中对它们执行任何操作。
原则上,也可以反其道而行之,将Russian/Cyrillic个字母映射到相应的普通模式命令,如nnoremap ш i
等。但是,这没有多大意义。
重点是 Vim 已经在 insert/replace 模式下内置了对国际键映射的支持。只需将 set keymap=russian-jcukenwin
添加到 vimrc 并在插入模式下使用 Ctrl6 即可在布局之间切换。
在正常模式下,您应该始终坚持 US/Latin。无需系统语言切换。
我用 xkblayout-state
解决了我的问题:每次打开 Vim 或通过此自动完成进入正常模式时,我只是用它切换系统语言布局:
" `0` is `en_US` in my case.
au VimEnter * silent !xkblayout-state set 0
au InsertLeave * silent !xkblayout-state set 0
我还在 Vi Stack Exchange 上找到了 this 解决方案:
To use langmap in greek you can follow the example given in
:h 'langmap'
adding this line to yourvimrc
(Copying this line from here may not be a good idea since I'm really not sure of the encoding, yanking the line directly from the help file is probably safer):langmap=ΑA,ΒB,ΨC,ΔD,ΕE,ΦF,ΓG,ΗH,ΙI,ΞJ,ΚK,ΛL,ΜM,ΝN,ΟO,ΠP,QQ,ΡR,ΣS,ΤT,ΘU,ΩV,WW,ΧX,ΥY,ΖZ,αa,βb,ψc,δd,εe,φf,γg,ηh,ιi,ξj,κk,λl,μm,νn,οo,πp,qq,ρr,σs,τt,θu,ωv,ςw,χx,υy,ζz