Files
vim-im-switch/COMPARISON.md
2025-12-05 13:34:29 +08:00

119 lines
2.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 项目文件对比
## 新增文件(使用 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 <IM_ID>
" 变量和函数
g:fcitx_*
Fcitx*()
```
### vim-im-switch-select.vim (新版 - im-select)
```vim
" 使用 im-select
executable("im-select")
system("im-select")
im-select <IM_ID>
" 变量和函数
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 进入 → 自动恢复中文输入法
## 使用建议
### 场景 1macOS 用户,已安装 fcitx-remote-for-osx
- 使用 `vim-im-switch.vim`(原版)
### 场景 2macOS 用户,使用 im-select
- 使用 `vim-im-switch-select.vim`(新版)
### 场景 3Linux 用户
- 使用 `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 已创建成功**
**逻辑与原版完全相同**
**所有测试通过**
**文档齐全**
可以立即投入使用!