LoginSignup
35
21

More than 5 years have passed since last update.

TerminalやMacVimでEsc (or ^[)キーで日本語IMEを英数に切り替える(Karabiner-Elementsによる設定)

Last updated at Posted at 2017-07-10

Karabiner-ElementsがVersion 0.91.6となって、待望の「アプリケーション毎のキーバインディング」がサポートされました。

macOS SierraでKarabinerが使えなくなって以来、私のようなVimユーザにとって「ESCキーで日本語入力をOFFにする」設定が何かと不便で困っていましたが、今回のKarabiner-ElementsのアップデートでなんとかKarabiner時代と同様の設定が可能となりました。有り難し!

設定方法

$ vim ~/.config/karabiner/assets/complex_modifications/FromEscapeToJapanese_eisuu.json

このFromEscapeToJapanese_eisuu.jsonファイルに次の内容を記述して保存。1

FromEscapeToJapanese_eisuu.json
{
  "title": "Terminal等でESCあるいは^[で日本語入力を英数に",
  "rules": [
    {
      "description": "TerminalまたはMacVimでESCあるいは^[を押したときに日本語入力を英数に切り替える。",
      "manipulators": [
        {
          "type": "basic",
          "from": { "key_code": "escape", "modifiers": { "optional": [ "any" ] } },
          "to": [ { "key_code": "japanese_eisuu" }, { "key_code": "escape" } ],
          "conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "^com\\.apple\\.Terminal$", "^org\\.vim\\." ] } ]
        },
        {
          "type": "basic",
          "from": { "key_code": "open_bracket", "modifiers": { "mandatory": ["left_control"] } },
          "to": [ { "key_code": "japanese_eisuu" }, { "key_code": "escape" } ],
          "conditions": [ { "type": "frontmost_application_if", "bundle_identifiers": [ "^com\\.apple\\.Terminal$", "^org\\.vim\\." ] } ]
        }
      ]
    }
  ]
}
  • Karabiner-Elements PreferencesウィンドウでComplex Modificationsメニューを開く

Screenshot 2017-07-10 11.22.50.png

  • 左下の"Add rule"をクリックすると次のような設定可能なルールの一覧が表示される。

Screenshot 2017-07-10 11.26.22.png

  • "ESCを押したときに日本語入力を英数に切り替える。"の右にある"Enable"をクリックする。
    Screenshot 2017-07-10 11.27.48.png

  • "Complex Modifications"ウィンドウで当該ルールが追加されていることを確認。
    Screenshot 2017-07-10 11.28.17.png

以上で設定は終わりです。



  1. ここでは、TerminalアプリとVimアプリの起動時のみ有効になるように設定しています。他のアプリのbundle identifiersを調べたい場合は、Karabiner-ElementsのメインメニューからEventViewerを起動して"Frontmost Application"から調べることができます。 

35
21
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
35
21