a command line utility that helps you switch keyboard layout in Windows, especially made for vim.
list all installed keyboard layouts
get the index of current keyboard layout
switch to the given keyboard layout
Note: <index>
: The index displayed in list
command
0 => Chinese (Traditional) - US Keyboard
1 => US
2 => Japanese
3 => Chinese (Simplified) - US Keyboard
Then
kbswitch.exe set 0
: switch toChinese (Traditional) - US Keyboard
keyboardkbswitch.exe set 1
: switch toUS
keyboardkbswitch.exe set 2
: switch toJanpanese
keyboardkbswitch.exe set 3
: switch toChinese (Simplified) - US Keyboard
keyboard
save the current keyboard layout state
restore the saved state
show help message
show the current version
- Make sure kbswitch.exe is in your
PATH
. - Add the following lines to your init.lua
Note: Don't forget to change the <index>
of set
command.
local kb_switch_group = vim.api.nvim_create_augroup("KbSwitch", { clear = true })
vim.api.nvim_create_autocmd("InsertLeave", {
pattern = "*",
group = kb_switch_group,
callback = function()
vim.fn.jobstart("kbswitch cache && kbswitch.exe set 1")
end
})
vim.api.nvim_create_autocmd("InsertEnter", {
pattern = "*",
group = kb_switch_group,
callback = function()
vim.fn.jobstart("kbswitch restore")
end
})
Note: This also works in WSL.
- This program need to read from the registry.
- This program need to write to the
%TEMP%
directory.
I don't really know. But I guess it should at least work in Windows 8+ (I'm using Windows 11 64bit)
MIT