A simple yet practical VSCode extension that automatically switches to English input method when VSCode window gains focus.
中文
Features
- Automatic Input Method Switching: Automatically switches to English input method when you switch from other applications to VSCode
- Activation on Startup: Also switches input method when VSCode starts and gains focus
- Highly Configurable: Customizable input method identifier and command paths
- Lightweight and Efficient: Performs only a single task with minimal system resource usage
Prerequisites
This extension depends on the im-select tool, which you need to install first:
macOS
brew install im-select
Windows
Download im-select and add it to your system PATH.
Configuration Guide
- After installing the extension, open VSCode settings (press
Ctrl+,
or Cmd+,
)
- Search for "imSwitch" to find the extension settings
- Configure the following options:
imSwitch.englishIME
: (Required) The identifier for your English input method
- macOS example:
com.apple.keylayout.ABC
or com.apple.keylayout.US
- Windows example:
1033
(US English)
imSwitch.obtainIMCmd
: Command to get the current input method (default: im-select
)
imSwitch.switchIMCmd
: Command to switch input method (default: im-select {im}
)
imSwitch.debugLog
: Enable debug logging (default: false
)
To find the correct input method identifier:
- Switch to English input method
- Open terminal or command prompt
- Run the
im-select
command
- Copy the output value as your
imSwitch.englishIME
setting
settings.json Example
{
"imSwitch.englishIME": "com.apple.keylayout.ABC",
"imSwitch.obtainIMCmd": "/opt/homebrew/bin/im-select",
"imSwitch.switchIMCmd": "/opt/homebrew/bin/im-select {im}",
"imSwitch.debugLog": false
}
Troubleshooting
If the extension isn't working correctly:
- Confirm that im-select is properly installed and runnable from terminal
- Enable debug logging: set
imSwitch.debugLog
to true
- Check the output panel (View > Output, select "IM Switcher")
- Ensure your
englishIME
setting value is correct
- If using custom paths, make sure the command paths are accurate
Usage Tips
- This extension runs automatically in the background and doesn't require manual triggering
- It only switches when the current input method is not English, avoiding unnecessary operations
- If you frequently switch between multiple applications, this extension can significantly improve your input efficiency
Important Note
This extension only changes the input method state when VSCode gains focus, it doesn't interfere with input method settings in other applications.
License
MIT
Contribution
Issues and Pull Requests to improve this extension are welcome!