目的
MacのVSCodeのエディタのVIMで、NORMALモードに戻る時に、IMEをOFFにしたい。
ESCで戻る時も、ctrl + [ で戻る時もOFFにしたい。
環境
- MacBook Pro(14インチ、2021)macOS Monterey 12.2.1
- VSCode Version: 1.64.2 (Universal)
やること
- im-selectをインストール
- VSCodeの設定
やったこと
ime-selectをインストール
パーミッションは適切に設定してください。
% curl -Ls -o ~/Downloads/im-select https://github.com/daipeihust/im-select/raw/master/im-select-mac/out/apple/im-select
% sudo mv ~/Downloads/im-select /usr/local/bin/
% chmod 777 /usr/local/bin/im-select
im-selectの動作確認
# 日本語入力なし
% im-select
com.google.inputmethod.Japanese.Roman
# 日本語入力に切り替えて
% im-select
com.apple.inputmethod.Kotoeri.RomajiTyping.Japanese
VSCodeのsetting.jsonを設定
以下の設定を追記
setting.json
+ "vim.autoSwitchInputMethod.defaultIM": "com.apple.keylayout.ABC",
+ "vim.autoSwitchInputMethod.obtainIMCmd": "/usr/bin/true",
+ "vim.autoSwitchInputMethod.switchIMCmd": "/usr/local/bin/im-select {im}",
+ "vim.autoSwitchInputMethod.enable": true
動作確認
setting.jsonが正しく記述できていれば、保存直後から ESC と ctrol - [ でNORMALモードに戻る時に日本語入力がオフになっています。
終わりに
先人の方達のおかげで、簡単でした。