{"id":15945613,"url":"https://github.com/qianbinbin/vim-autoim","last_synced_at":"2026-04-30T10:33:00.900Z","repository":{"id":218006535,"uuid":"745352171","full_name":"qianbinbin/vim-autoim","owner":"qianbinbin","description":"macOS 版 Vim 自动切换输入法 | Automatically switches input methods for Vim on macOS","archived":false,"fork":false,"pushed_at":"2024-01-22T06:17:02.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T10:11:49.212Z","etag":null,"topics":["macos","vim","vim-plugin"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qianbinbin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2024-01-19T06:33:05.000Z","updated_at":"2024-01-19T17:51:12.000Z","dependencies_parsed_at":"2024-01-19T08:51:27.365Z","dependency_job_id":"493e2b3b-cd84-4bde-b761-7fc84c50acaa","html_url":"https://github.com/qianbinbin/vim-autoim","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"cbabd780c1a30c417f3c435429e8efdadd975db0"},"previous_names":["qianbinbin/vim-autoim"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qianbinbin%2Fvim-autoim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qianbinbin%2Fvim-autoim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qianbinbin%2Fvim-autoim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qianbinbin%2Fvim-autoim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qianbinbin","download_url":"https://codeload.github.com/qianbinbin/vim-autoim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247086024,"owners_count":20881160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["macos","vim","vim-plugin"],"created_at":"2024-10-07T09:04:30.091Z","updated_at":"2026-04-30T10:32:55.878Z","avatar_url":"https://github.com/qianbinbin.png","language":"Vim Script","funding_links":[],"categories":[],"sub_categories":[],"readme":"[English](#English)\n\n***\n\n## vim-autoim\n\n这是 macOS 版 Vim 自动切换输入法的插件，它只做两件事：\n\n* 进入输入模式时，恢复到上次的输入法。\n* 退出输入模式时，切换到英文输入法。\n\n### 前提条件\n\n* 系统配置单独的英文输入法，如“美国”或“ABC”。\n* 开启 Ctrl + Space 切换输入法的快捷键。\n\n### 安装\n\n#### [vim-plug](https://github.com/junegunn/vim-plug)\n\n```vim\nPlug 'qianbinbin/vim-autoim'\n```\n\n### 配置\n\n#### 默认英文输入法\n\n切换到英文输入法，并运行以下命令获取英文输入法的 ID：\n\n```sh\ndefaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleCurrentKeyboardLayoutInputSourceID\n```\n\n如结果为 `com.apple.keylayout.US` 则无需配置，否则在 `~/.vimrc` 中加入：\n\n```vim\nlet g:autoim_en = 'com.apple.keylayout.US'\n```\n\n将 `com.apple.keylayout.US` 改为你自己的英文输入法 ID，如 `com.apple.keylayout.ABC`。\n\n#### 允许使用辅助功能\n\n首次使用时，你的终端或 iTerm 等会要求使用辅助功能，允许即可。这是因为插件需要模拟键盘操作。\n\n#### 减小延迟\n\n如果你在退出输入模式时感到延迟，在 `~/.vimrc` 加入：\n\n```vim\nset ttimeoutlen=0\n```\n\n注意 `ttimeoutlen` 不是 `timeoutlen`，后者会造成组合键映射失效。\n\n### 感谢\n\n* [自动切换 vim 中文输入法](https://taoshu.in/vim/vim-auto-im.html)\n* [smartim](https://github.com/ybian/smartim)\n* [vimrc - Usage of timeoutlen and ttimeoutlen - Vi and Vim Stack Exchange](https://vi.stackexchange.com/a/24938)\n* [Eliminating delays on ESC in vim and zsh - John Hawthorn](https://www.johnhawthorn.com/2012/09/vi-escape-delays/)\n* [Delay when entering Insert mode in a terminal buffer · Issue #3743 · neovim/neovim](https://github.com/neovim/neovim/issues/3743#issuecomment-159642147)\n\n### 为什么不使用 smartim\n\nsmartim 使用的 im-select 有概率性 bug：在进入输入模式并自动切换输入法后，即使菜单栏已经显示切换成功，输入的仍是英文。\n\n***\n\n## English\n\nThis is a plugin for Vim on macOS that automatically switches input methods.\nIt just does two things:\n\n* When entering insert mode, restore the last used input method.\n* When leaving insert mode, switch to English input method.\n\n### Prerequisites\n\n* Set up a separate English input method, such as \"U.S.\" or \"ABC\".\n* Enable the shortcut key Ctrl + Space for switching input methods.\n\n### Installation\n\n#### [vim-plug](https://github.com/junegunn/vim-plug)\n\n```vim\nPlug 'qianbinbin/vim-autoim'\n```\n\n### Configuration\n\n#### The Default English Input Method\n\nSwitch to the English input method and execute the following command to obtain the ID:\n\n```sh\ndefaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleCurrentKeyboardLayoutInputSourceID\n```\n\nIf the output is `com.apple.keylayout.US`, no further configuration is needed.\nOtherwise, add the following line to `~/.vimrc`:\n\n```vim\nlet g:autoim_en = 'com.apple.keylayout.US'\n```\n\nReplace `com.apple.keylayout.US` with your own English input method ID, such as `com.apple.keylayout.ABC`.\n\n#### Allow Accessibility Access\n\nUpon first usage, your terminal APP will prompt for accessibility access.\nPlease allow it as the plugin requires simulating keyboard operations.\n\n#### Reduce Latency\n\nIf you experience a delay when leaving insert mode, add the following line to `~/.vimrc`:\n\n```vim\nset ttimeoutlen=0\n```\n\nNote that `ttimeoutlen` is not the same as `timeoutlen`,\nas the latter can cause the mappings to fail.\n\n### Credits\n\n* [自动切换 vim 中文输入法](https://taoshu.in/vim/vim-auto-im.html)\n* [smartim](https://github.com/ybian/smartim)\n* [vimrc - Usage of timeoutlen and ttimeoutlen - Vi and Vim Stack Exchange](https://vi.stackexchange.com/a/24938)\n* [Eliminating delays on ESC in vim and zsh - John Hawthorn](https://www.johnhawthorn.com/2012/09/vi-escape-delays/)\n* [Delay when entering Insert mode in a terminal buffer · Issue #3743 · neovim/neovim](https://github.com/neovim/neovim/issues/3743#issuecomment-159642147)\n\n### Why Not smartim\n\nThere is a probabilistic bug with `im-select` used by smartim.\nEven after entering insert mode and automatically restoring the input method,\nthere are cases where the input remains in English,\ndespite the input method being successfully displayed in the menu bar.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqianbinbin%2Fvim-autoim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqianbinbin%2Fvim-autoim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqianbinbin%2Fvim-autoim/lists"}