LoginSignup
79
46

More than 3 years have passed since last update.

Win版の VS Code+VSCodeVim でノーマルモードに戻った時にIMEを半角英数入力にする

Last updated at Posted at 2019-08-22

VSCodeVimのreadme を見ると im-select を使えとのことでしたが、なんか思ってたのと違うっぽいのでWin32API叩いて半角/全角を切り替えることにしました。

プログラムを用意する

github: https://github.com/iuchim/zenhan
実行ファイル

自分でビルドするか上のzipファイルに入ってる zenhan.exe をお好きな場所にコピーしておいてください。
今回は C:\Users\foo\bin にコピーしたとします。

VSCodeVim の autoSwitchInputMethod を設定

settings.json に次の設定を追加します。

    "vim.autoSwitchInputMethod.enable": true,
    "vim.autoSwitchInputMethod.defaultIM": "0",
    "vim.autoSwitchInputMethod.obtainIMCmd": "C:\\users\\foo\\bin\\zenhan.exe",
    "vim.autoSwitchInputMethod.switchIMCmd": "C:\\users\\foo\\bin\\zenhan.exe {im}",

保存したら完了です。

この設定だと、インサートモードに戻った時にIMEの状態を復元してくれますが、個人的には半角のままのほうが好みなので obtainIMCmd を次のようにしています。

    "vim.autoSwitchInputMethod.obtainIMCmd": "C:\\users\\foo\\bin\\zenhan.exe 0",

参考にしたもの

大変参考になったというか、2つを混ぜて作りました。
ありがとうございます。

79
46
7

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
79
46