VSCode VIM 自动切换输入法
· 2 min read
下载 im-select
Windows系统, 根据情况下载:
macOS, 根据情况下载:
如果GitHub无法下载,可以使用百度网盘下载 链接: https://pan.baidu.com/s/1xNwoIYopbzzx5qvA_3s2YQ?pwd=iqev 提取码: iqev
配置
VSCode 的 VIM 支持以下配置项:
Setting | Description |
---|---|
vim.autoSwitchInputMethod.enable | 是否启用 autoSwitchInputMethod |
vim.autoSwitchInputMethod.defaultIM | 默认输入法的名字, 也就是进入到命令模式时使用的输入法 |
vim.autoSwitchInputMethod.obtainIMCmd | 获取系统输入法状态的命令, 用于检测当前使用的什么输入法 |
vim.autoSwitchInputMethod.switchIMCmd | 切换输入法的命令 |
检测默认输入法名字
第一步: 下载好 im-select
命令之后, 把输入法切换成VIM命令行模式下想要使用的输入法(一般是英文输入法), 然后使用命令检测当前的名字:
im-select # 我的系统显示 com.apple.keylayout.ABC
第二步: VSCode增加以下设置(Ctrl + ,
/ cmd + ,
)
macOS
{
"vim.autoSwitchInputMethod.enable": true,
"vim.autoSwitchInputMethod.defaultIM": "com.apple.keylayout.ABC", // 这里根据自己执行 im-select 实际输出结果设置
"vim.autoSwitchInputMethod.obtainIMCmd": "/usr/local/bin/im-select", // 这里的路径,也要根据自己的 im-select 命令文件存放位置设置
"vim.autoSwitchInputMethod.switchIMCmd": "/usr/local/bin/im-select {im}"
}
Windows
{
"vim.autoSwitchInputMethod.enable": true,
"vim.autoSwitchInputMethod.defaultIM": "1033", // 这里根据自己执行 im-select 实际输出结果设置
"vim.autoSwitchInputMethod.obtainIMCmd": "D:\\bin\\im-select.exe", // 这里的路径,也要根据自己的 im-select 命令文件存放位置设置
"vim.autoSwitchInputMethod.switchIMCmd": "D:\\bin\\im-select.exe {im}"
}