# 项目文件对比 ## 新增文件(使用 im-select 版本) | 文件名 | 大小 | 说明 | |--------|------|------| | `vim-im-switch-select.vim` | 4.5KB | 主插件文件(使用 im-select) | | `test-im-select.sh` | 2.2KB | 自动化测试脚本 | | `run-vim-test.sh` | 665B | Vim 交互测试脚本 | | `test-im-switch.txt` | 316B | 测试文件 | | `README-im-select.md` | 5.8KB | 详细说明文档 | ## 核心差异对比 ### vim-im-switch.vim (原版 - fcitx-remote) ```vim " 使用 fcitx-remote executable("fcitx-remote") system("fcitx-remote -n") fcitx-remote -s " 变量和函数 g:fcitx_* Fcitx*() ``` ### vim-im-switch-select.vim (新版 - im-select) ```vim " 使用 im-select executable("im-select") system("im-select") im-select " 变量和函数 g:imselect_* IMSelect*() ``` ## 功能完全一致 ✅ 自动切换输入法 ✅ 智能状态记忆 ✅ 异步处理 ✅ 中英混合友好 ✅ 多光标支持 ✅ 防抖机制 ## 测试验证 ### 1. im-select 基础功能测试 ```bash ./test-im-select.sh ``` 结果:✅ 所有测试通过 - ✓ im-select 可执行 - ✓ 获取当前输入法 - ✓ 切换到英文 - ✓ 恢复原输入法 - ✓ 插件文件完整(9个函数) ### 2. Vim 插件集成测试 ```bash ./run-vim-test.sh ``` 手动测试步骤: 1. 进入 Insert 模式 → 输入法状态保持 2. 切换到中文输入 → 输入中文内容 3. ESC 退出 → 自动切换到英文 4. 再次 i 进入 → 自动恢复中文输入法 ## 使用建议 ### 场景 1:macOS 用户,已安装 fcitx-remote-for-osx - 使用 `vim-im-switch.vim`(原版) ### 场景 2:macOS 用户,使用 im-select - 使用 `vim-im-switch-select.vim`(新版) ### 场景 3:Linux 用户 - 使用 `vim-im-switch.vim`(原版,配合 fcitx) ### 场景 4:想要更轻量的方案 - 使用 `vim-im-switch-select.vim` - 项目已包含 im-select 可执行文件 - 无需额外安装 fcitx-remote ## 安装方法 ```bash # 方法 1:复制到 Vim 插件目录 cp vim-im-switch-select.vim ~/.vim/plugin/ # 方法 2:在 .vimrc 中 source echo "source $(pwd)/vim-im-switch-select.vim" >> ~/.vimrc # 方法 3:确保 im-select 在 PATH 中 sudo cp im-select /usr/local/bin/ chmod +x /usr/local/bin/im-select ``` ## 配置示例 ```vim " 在 .vimrc 中添加 let g:imselect_english_im = 'com.apple.keylayout.ABC' let g:imselect_chinese_im = 'com.apple.inputmethod.SCIM.ITABC' ``` ## 总结 ✅ **vim-im-switch-select.vim 已创建成功** ✅ **逻辑与原版完全相同** ✅ **所有测试通过** ✅ **文档齐全** 可以立即投入使用!