{"id":15654433,"url":"https://github.com/orangex4/vscode-smart-ime","last_synced_at":"2025-04-30T23:48:02.236Z","repository":{"id":199858185,"uuid":"703557050","full_name":"OrangeX4/vscode-smart-ime","owner":"OrangeX4","description":"在 VS Code 中智能地进行中英输入法的切换","archived":false,"fork":false,"pushed_at":"2023-10-23T02:38:59.000Z","size":559,"stargazers_count":40,"open_issues_count":6,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-30T23:47:54.963Z","etag":null,"topics":["chinese","input-method","vscode"],"latest_commit_sha":null,"homepage":"https://marketplace.visualstudio.com/items?itemName=OrangeX4.vscode-smart-ime","language":"TypeScript","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/OrangeX4.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-11T13:16:14.000Z","updated_at":"2025-04-20T15:01:02.000Z","dependencies_parsed_at":"2023-10-13T00:51:04.465Z","dependency_job_id":"98e699fc-191e-4d1f-ae64-6bfef09302e2","html_url":"https://github.com/OrangeX4/vscode-smart-ime","commit_stats":null,"previous_names":["orangex4/vscode-smart-ime"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrangeX4%2Fvscode-smart-ime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrangeX4%2Fvscode-smart-ime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrangeX4%2Fvscode-smart-ime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrangeX4%2Fvscode-smart-ime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OrangeX4","download_url":"https://codeload.github.com/OrangeX4/vscode-smart-ime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251801086,"owners_count":21645968,"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":["chinese","input-method","vscode"],"created_at":"2024-10-03T12:51:45.939Z","updated_at":"2025-04-30T23:48:02.213Z","avatar_url":"https://github.com/OrangeX4.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](./icon.png)\n\n# Smart IME\n\n灵感来自 idea 的 Smart Input，用于智能地进行中英输入法的切换。\n\n**依赖于 [IME and Cursor](https://marketplace.visualstudio.com/items?itemName=beishanyufu.ime-and-cursor) 插件，所以请先进行该插件的配置，例如可以配置中文输入法时显示为红色光标。**\n\n## 依赖\n\n需要安装 [IME and Cursor](https://marketplace.visualstudio.com/items?itemName=beishanyufu.ime-and-cursor) 与 HyperScopes 插件。\n\n## 特性\n\n![](./smart-ime.gif)\n\n- 检测到前一个字符是中文时自动切换到中文输入法（默认开启，**这个特性较为耗电，请仔细甄别是否要开启，以及配置触发间隔时间，默认为 2 秒**）；\n- 在中文后输入一个空格自动切换到英文输入法（默认开启）；\n- 在英文后输入两个空格自动切换到中文输入法（默认未开启）；\n- 进入到注释场景时，自动切换为中文输入法，离开时自动切换为英文输入法（参考插件配置里的 `comment` 相关内容）；\n- 进入到数学公式时，自动切换为英文输入法，离开时自动切换为中文输入法（参考插件配置里的 `markup.math,meta.math` 相关内容）；\n- 离开字符串时，自动切换为英文输入法（参考插件里的 `string` 相关内容，如果要进入字符串后自动切换成中文可以自行配置）；\n- 如果当前文档拥有超过 n 个英文字符且没有中文字符，则禁用插件；\n  - 只有在切换窗口时重新检测\n- 当然，你也可以在文档中加入一个字符串 `DISABLE_SMART_IME`（例如在注释块里写这个字符串），只要识别到当前文档有这个字符串，也会在当前文件禁用插件；\n  - 只有在切换窗口时重新检测；\n- 在 Vim Normal 模式下禁用自动切换，不过目前识别 Vim Normal 模式仅是根据光标状态识别，可能存在 bug。\n\n\n## 获取输入法的 key 失败，请检查是否正确设置了 \"ObtainIMCmd\"\n\n请搜索插件 [IME and cursor](https://marketplace.visualstudio.com/items?itemName=beishanyufu.ime-and-cursor)，并按插件说明进行相应的安装和配置。\n\n\n## 切换输入法无法切换光标样式\n\n请使用 `shift + space` 切换输入法，而不是使用系统自带的快捷键。搜索插件 [IME and cursor](https://marketplace.visualstudio.com/items?itemName=beishanyufu.ime-and-cursor) 查看更详细的说明。\n\n\n## 在 remote / SSH / WSL / docker 模式下使用\n\n如果无法在 remote 状态下生效，可以试着先在 remote 删除 Smart IME 以及其依赖的两个插件，然后在 remote 的设置中加入如下设置：\n\n```json\n\"remote.extensionKind\": {\n  \"draivin.hscopes\": [\"ui\"],\n  \"beishanyufu.ime-and-cursor\": [\"ui\"],\n  \"OrangeX4.vscode-smart-ime\": [\"ui\"]\n}\n```\n\n再重新安装插件即可。\n\n\n## 目前的问题\n\n- VS Code 并没有给出一个很好的 api 来判断终端是否获得了焦点，因此切换到终端时切换到英文输入法的功能暂时无法实现；\n- Commit Message 同理，暂时无法实现；\n- Vim 模式的支持可以使用 IME and Cursor 里的配置实现；\n\n## 插件设置\n\n- `smart-ime.warnDisabled`: 是否显示禁用提示\n- `smart-ime.disabledOnEnglishTextOverN`: 如果当前文档拥有超过 n 个英文字符且没有中文字符，则禁用插件，默认为 100，值为 -1 时禁用该设置\n- `smart-ime.enableChineseSwitchToChinese`: 检测到中文时切换输入法到中文，默认开启\n- `smart-ime.enableChineseSwitchToChineseInterval`: 检测到中文时切换输入法到中文的触发间隔，默认 2000 毫秒（即两秒）\n- `smart-ime.enableChineseAndSpaceSwitchToEnglish`: 检测到中文+空格时切换输入法到英文，默认开启\n- `smart-ime.enableEnglishAndDoubleSpaceSwitchToChinese`: 检测到当前行前有中文，且光标前面是非中文+双空格时切换输入法到中文并删掉一个空格，默认关闭\n- `smart-ime.enterScopesSwitchToChinese`: 进入某些 scopes 时切换输入法到中文，用逗号分割，前缀匹配，请使用 `Developer: Inspect Editor Tokens and Scopes` 查看当前位置的 scopes\n  - 例如这里默认配置了 `comment` 就可以实现进入注释块时切换到中文输入法的效果\n  - 如果配置了 `comment,string`，就可以匹配 Python 的 `comment.line.number-sign.python`（注释）和 `string.quoted.single.python`（字符串），请使用 `Developer: Inspect Editor Tokens and Scopes` 命令查看 scopes\n- `smart-ime.enterScopesSwitchToEnglish`: 进入某些 scopes 时切换输入法到英文，用逗号分割，前缀匹配\n  - 例如这里默认配置了 `markup.math,meta.math` 就可以实现进入数学公式（markdown 和 latex）时切换到英文输入法的效果\n- `smart-ime.leaveScopesSwitchToChinese`: 离开某些 scopes 时切换输入法到中文，用逗号分割，前缀匹配\n  - 例如这里默认配置了 `markup.math,meta.math` 就可以实现离开数学公式（markdown 和 latex）时切换到中文输入法的效果\n- `smart-ime.leaveScopesSwitchToEnglish`: 离开某些 scopes 时切换输入法到中文，用逗号分割，前缀匹配\n  - 例如这里默认配置了 `comment,string` 就可以实现离开注释块和字符串时切换到英文输入法的效果\n- `smart-ime.disabledOnVim`: 在 Vim Normal 模式下禁用自动切换，不过目前识别 Vim Normal 模式仅是根据光标状态识别，可能存在 bug\n- 优先级是 **优先英文切换** 和 **优先进入切换**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forangex4%2Fvscode-smart-ime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forangex4%2Fvscode-smart-ime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forangex4%2Fvscode-smart-ime/lists"}