InputKiCor automatically switches between English and your mother-tongue input mode according to the cursor context in VS Code.
InputKiCor 会根据 VS Code 中的光标上下文,在英文与母语输入状态之间自动切换。
The VS Code adapter is intentionally small. Context analysis, switching decisions, and native input-method control run in a persistent Rust sidecar to keep extension-host memory use low.
VS Code 适配层保持轻量;上下文分析、切换决策和系统输入法控制均由常驻 Rust 辅助进程完成,以降低扩展宿主的内存占用。
Features / 功能
- Detects code, strings, normal comments, documentation comments, plain-text documents, Vim Normal mode, and custom regex contexts.
识别代码、字符串、普通注释、文档注释、纯文本文档、Vim 普通模式和自定义正则上下文。
- Preserves a manual input-method change while the cursor remains in the same context.
光标未离开当前上下文时,保留用户手动切换的输入法,不会强制切回。
- Applies an independent default language whenever focus enters the integrated terminal.
每次进入集成终端时应用独立的默认语言,并允许进入后手动切换。
- Supports data-driven comment syntax for languages not built into the extension.
可通过设置为未内置的语言添加注释语法,无需修改或重新编译 Rust 代码。
- Replaces configurable Chinese/full-width symbols only in selected file types.
可仅在指定文件类型中替换自定义中文/全角符号。
- Shows a lightweight inline restore hint beside the cursor;
Ctrl+Alt+Z restores the latest symbol replacement.
替换后在光标附近显示轻量提示,按 Ctrl+Alt+Z 可还原最近一次符号替换。
- Windows 10/11: IMM32 state control with an optional hotkey fallback.
Windows 10/11:使用 IMM32 控制输入状态,并支持按键切换作为回退方案。
- Linux x64: Fcitx5 through
fcitx5-remote, or IBus through ibus.
Linux x64:支持通过 fcitx5-remote 控制 Fcitx5,或通过 ibus 控制 IBus。
Interface language / 界面语言
Commands, settings, status-bar details, and runtime text follow VS Code's display language. Chinese (zh-*) and English are included; other locales fall back to English.
命令、设置、状态栏详情和运行时文本默认跟随 VS Code 的显示语言。项目内置中文(zh-*)与英文,其他语言环境回退为英文。
Basic configuration / 基础配置
Open Preferences: Open User Settings (JSON) or a workspace .vscode/settings.json and add the options you need.
打开 Preferences: Open User Settings (JSON),或者编辑工作区的 .vscode/settings.json,加入所需配置。
{
"inputkicor.enabled": true,
"inputkicor.autoSwitch": true,
// Code/default contexts use English.
// 代码和默认上下文使用英文。
"inputkicor.codeDefault": "english",
// Code and strings use English; plain text, comments, and docs use the mother tongue.
// 代码和字符串使用英文;纯文本、普通注释和文档注释使用母语。
"inputkicor.textDefault": "mother_tongue",
"inputkicor.stringLanguage": "english",
"inputkicor.commentLanguage": "mother_tongue",
"inputkicor.docCommentLanguage": "mother_tongue",
"inputkicor.textLanguageIds": [
"markdown",
"plaintext",
"restructuredtext",
"latex"
],
// Apply English once whenever focus enters a terminal.
// 每次进入终端时切换为英文。
"inputkicor.terminal.language": "english"
}
Language targets accept three values:
语言目标支持三个值:
english: switch to English / 切换为英文;
mother_tongue: switch to the configured mother-tongue input mode / 切换为母语输入状态;
no_change: preserve the current input method / 保持当前输入法状态。
Automatic switching behavior / 自动切换行为
InputKiCor switches only when the effective context changes. For example, moving from Rust code into a comment can switch from English to Chinese. If you then manually choose English while staying inside that comment, the extension preserves English until the cursor enters another context.
InputKiCor 仅在有效上下文发生变化时自动切换。例如,从 Rust 代码进入注释时可以由英文切换为中文;如果随后在该注释内手动切回英文,插件会保留英文,直到光标进入其他上下文。
By default, code and strings use english, while ordinary comments, documentation comments, and plain-text files use mother_tongue. The stringLanguage, commentLanguage, and docCommentLanguage settings can each be changed to english, mother_tongue, or no_change. The default plain-text language is controlled by textDefault. Files are treated as plain text when their VS Code language ID appears in textLanguageIds.
默认情况下,代码和字符串使用 english,普通注释、文档注释和纯文本文件使用 mother_tongue。stringLanguage、commentLanguage 和 docCommentLanguage 均可单独改为 english、mother_tongue 或 no_change。纯文本文档的默认语言由 textDefault 控制。当文件的 VS Code 语言 ID 位于 textLanguageIds 中时,会按纯文本处理。
Built-in profiles cover C/C++, C#, Java, JavaScript/TypeScript, Rust, Swift, Go, Dart, CSS, PHP, Vue/Svelte/Astro, Python, shell scripts, Ruby, Perl, R, SQL, HTML/XML, PowerShell, Lua, Haskell, OCaml, Lisp-family languages, MATLAB, YAML, TOML, INI, Batch, Visual Basic, and Elixir.
内置规则覆盖 C/C++、C#、Java、JavaScript/TypeScript、Rust、Swift、Go、Dart、CSS、PHP、Vue/Svelte/Astro、Python、Shell、Ruby、Perl、R、SQL、HTML/XML、PowerShell、Lua、Haskell、OCaml、Lisp 系语言、MATLAB、YAML、TOML、INI、Batch、Visual Basic 和 Elixir。
To support another language, first check its VS Code language ID by clicking the language indicator in the lower-right corner and opening Change Language Mode. Then add a profile:
若要支持其他语言,先点击 VS Code 右下角的语言指示器,确认其语言 ID,然后添加配置:
{
"inputkicor.commentLanguage": "mother_tongue",
"inputkicor.docCommentLanguage": "mother_tongue",
"inputkicor.languageProfiles": [
{
// A profile matches when either languageIds or fileExtensions matches.
// languageIds 或 fileExtensions 任意一项匹配即可应用此规则。
"languageIds": ["my-language"],
"fileExtensions": [".mylang", ".templ"],
// false extends a built-in profile; true replaces its comment delimiters.
// false 表示扩展内置规则;true 表示替换内置注释分隔符。
"replaceBuiltin": false,
"lineComments": ["//", "#"],
"docLineComments": ["///"],
"blockComments": [
{ "start": "/*", "end": "*/", "nested": false },
{ "start": "(*", "end": "*)", "nested": true }
],
"docBlockComments": [
{ "start": "/**", "end": "*/", "nested": false }
]
}
]
}
Field behavior / 字段说明:
languageIds: VS Code language IDs, case-insensitive / VS Code 语言 ID,不区分大小写;
fileExtensions: extensions with or without a leading dot / 文件扩展名,可带或不带前导点;
lineComments: normal single-line markers / 普通单行注释标记;
docLineComments: documentation single-line markers / 文档单行注释标记;
blockComments: normal block delimiters / 普通块注释分隔符;
docBlockComments: documentation block delimiters / 文档块注释分隔符;
nested: whether the block format permits nested comments / 此类块注释是否允许嵌套;
replaceBuiltin: replace built-in comment markers instead of extending them / 替换内置注释规则,而不是追加规则。
Longer markers such as /// and /** are matched before shorter markers such as // and /*.
插件会优先匹配 ///、/** 等较长标记,再匹配 //、/* 等较短标记。
Custom symbol replacement / 自定义符号替换
Symbol replacement is disabled by default. The following example enables only selected symbols in Markdown, text, Rust, and a custom file type:
符号替换默认关闭。下面的示例仅在 Markdown、文本、Rust 和自定义文件类型中启用指定符号:
{
"inputkicor.symbolReplacement.enabled": true,
// Empty means every file type.
// 空数组表示对所有文件类型生效。
"inputkicor.symbolReplacement.fileExtensions": [
".md",
".txt",
".rs",
".mylang"
],
// Empty means every entry in rules; otherwise this is an allowlist.
// 空数组表示允许 rules 中的所有规则;非空时作为符号白名单。
"inputkicor.symbolReplacement.symbols": [
",",
"。",
":",
";",
"(",
")",
"“",
"”"
],
// Entries extend or override the built-in defaults.
// 配置项会追加或覆盖内置默认映射。
"inputkicor.symbolReplacement.rules": {
",": ",",
"。": ".",
":": ":",
";": ";",
"(": "(",
")": ")",
"“": "\"",
"”": "\"",
// Mapping a source to itself disables an inherited rule.
// 将源字符映射为自身,可禁用该条内置规则。
"!": "!"
}
}
fileExtensions is case-insensitive and accepts values with or without .. An empty list enables replacement in all file types. symbols is an allowlist; an empty list enables every valid entry in rules.
fileExtensions 不区分大小写,扩展名可带或不带 .;空数组表示所有文件类型。symbols 是允许替换的符号白名单;空数组表示启用 rules 中所有有效映射。
After a replacement, an inline hint appears beside the cursor. Press Ctrl+Alt+Z before the next real edit to restore the original symbol. The shortcut can be changed in VS Code's Keyboard Shortcuts editor by searching for InputKiCor: Restore Last Replaced Symbol.
发生替换后,光标附近会显示内联还原提示。在下一次真实编辑前按 Ctrl+Alt+Z,即可恢复原始符号。可在 VS Code 键盘快捷方式页面搜索“InputKiCor:还原上次替换的符号”来自定义快捷键。
Terminal language / 终端默认语言
Set inputkicor.terminal.language to english, mother_tongue, or no_change. The target is applied once when focus enters a terminal; manual changes are preserved until focus leaves and enters a terminal again.
将 inputkicor.terminal.language 设置为 english、mother_tongue 或 no_change。插件只在焦点进入终端时应用一次目标语言;进入终端后的手动切换会被保留,直到焦点离开并再次进入终端。
Ctrl+Backtick runs InputKiCor: Focus Terminal with Default Input Language while the terminal is not focused.
终端未聚焦时,Ctrl+反引号 会执行“InputKiCor:使用默认输入语言聚焦终端”。
Windows settings / Windows 设置
inputkicor.windows.strategy supports:
inputkicor.windows.strategy 支持:
auto: try IMM32, verify the state, then use the configured hotkey as fallback / 先尝试 IMM32 并验证状态,失败后使用配置的切换按键;
imm32: use only direct IMM32 state control / 仅使用 IMM32 直接控制;
hotkey: always use the configured toggle key / 始终使用配置的切换按键。
Set inputkicor.windows.hotkey to shift, caps_lock, or ctrl_space according to the input method's own language-toggle shortcut.
根据输入法自身的中英文切换按键,将 inputkicor.windows.hotkey 设置为 shift、caps_lock 或 ctrl_space。
Linux settings / Linux 设置
Set inputkicor.linux.backend to auto, fcitx5, or ibus. The corresponding command must be available in PATH. If IBus mother-tongue detection has not observed the desired engine, set inputkicor.linux.motherTongueEngine, for example rime or libpinyin.
将 inputkicor.linux.backend 设置为 auto、fcitx5 或 ibus,并确保对应命令位于 PATH。如果 IBus 尚未识别目标母语引擎,请配置 inputkicor.linux.motherTongueEngine,例如 rime 或 libpinyin。
Commands / 命令
InputKiCor: Toggle / 启用或禁用插件;
InputKiCor: Pause/Resume Automatic Switching / 暂停或恢复自动切换;
InputKiCor: Switch to English / 切换到英文;
InputKiCor: Switch to Mother Tongue / 切换到母语;
InputKiCor: Focus Terminal with Default Input Language / 使用默认输入语言聚焦终端;
InputKiCor: Restore Last Replaced Symbol / 还原上次替换的符号;
InputKiCor: Restart Rust Sidecar / 重启 Rust 辅助进程。