0
1

More than 1 year has passed since last update.

VScode + Vim Extention / Normalモードに入ったら日本語入力を解除する

Last updated at Posted at 2021-11-08

問題

VScode+Vim Extentionでコードを書いているとき、デフォルトのままだとInsertモードで日本語を入力したあと、Insertモードに戻るとする。
すると日本語入力が維持されているためカーソル移動すると っっっっh みたいに入力されて悲しくなる。
これをなんとかしたい。

環境

  • macOS Big Sur 11.6
  • Visual Studio Code 1.62.0
  • Vim Extention v1.21.10

解決方法

公式に書いてある解決策を使う。

まずim-select をインストールする。

curl -Ls https://raw.githubusercontent.com/daipeihust/im-select/master/install_mac.sh | sh

その後、VScodeのユーザー設定に以下を追記。

{
  "vim.autoSwitchInputMethod.enable": true,
  "vim.autoSwitchInputMethod.obtainIMCmd": "/usr/local/bin/im-select",
  "vim.autoSwitchInputMethod.switchIMCmd": "/usr/local/bin/im-select {im}",
  "vim.autoSwitchInputMethod.defaultIM": "com.apple.keylayout.ABC",
}

これでInsertモードからNormalモードに戻ったとき、日本語入力が解除されるようになる。

ちなみに

この状態だと再度Insertモードに入ったとき、日本語入力が維持されている状態になる。
これも嫌な場合は以下のようにする。

{
  "vim.autoSwitchInputMethod.enable": true,
  "vim.autoSwitchInputMethod.obtainIMCmd": "/usr/bin/true",
  "vim.autoSwitchInputMethod.switchIMCmd": "/usr/local/bin/im-select {im}",
  "vim.autoSwitchInputMethod.defaultIM": "com.apple.keylayout.ABC",
}

コピペしやすいように全文乗せているが、上で書いたものとの違いは vim.autoSwitchInputMethod.obtainIMCmd のみ。

参考にしたもの

https://qiita.com/altus/items/334aaa27fb2c7b73b837
https://note.com/5mingame2/n/n88d7ceae5a95

0
1
0

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
0
1