Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Sublime Text2で日本語で検索しようとすると入力文字が消えてしまう事象への対応

f:id:tbpg:20151202232414p:plain

Sublime Text2で日本語で検索しようとすると、
デフォルトのショートカットキーの設定が enter になっている関係で入力文字列が消えてしまいます。

対応手順

Preferences - Key Bindings - Defaultの設定変更

まずは enter の設定を無効化します。

  • command+fのFind
  • command+option+fのReplace
  • command+shift+fのFind in Files

の3箇所のキーバインドを無効化します。

  // Find panel key bindings
  // 以下の設定をコメントアウト
  // { "keys": ["enter"], "command": "find_next", "context":
    // [{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}]
  // },
  { "keys": ["shift+enter"], "command": "find_prev", "context":
    [{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}]
  },
  { "keys": ["alt+enter"], "command": "find_all", "args": {"close_panel": true},
     "context": [{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}]
  },

  // Replace panel key bindings
  // 以下の設定をコメントアウト
  // { "keys": ["enter"], "command": "find_next", "context":
    // [{"key": "panel", "operand": "replace"}, {"key": "panel_has_focus"}]
  // },
  { "keys": ["shift+enter"], "command": "find_prev", "context":
    [{"key": "panel", "operand": "replace"}, {"key": "panel_has_focus"}]
  },
  { "keys": ["alt+enter"], "command": "find_all", "args": {"close_panel": true},
    "context": [{"key": "panel", "operand": "replace"}, {"key": "panel_has_focus"}]
  },
  { "keys": ["ctrl+alt+enter"], "command": "replace_all", "args": {"close_panel": true},
     "context": [{"key": "panel", "operand": "replace"}, {"key": "panel_has_focus"}]
  },

  // Incremental find panel key bindings
  // 以下の設定をコメントアウト
  // { "keys": ["enter"], "command": "hide_panel", "context":
    // [{"key": "panel", "operand": "incremental_find"}, {"key": "panel_has_focus"}]
  // },
  { "keys": ["shift+enter"], "command": "find_prev", "context":
    [{"key": "panel", "operand": "incremental_find"}, {"key": "panel_has_focus"}]
  },
  { "keys": ["alt+enter"], "command": "find_all", "args": {"close_panel": true},
    "context": [{"key": "panel", "operand": "incremental_find"}, {"key": "panel_has_focus"}]
  },

Preferences - Key Bindings - Userの設定追加

任意のキーバインドenter の代わりのキーを設定します。
私は command+enter を設定しましたが、好きなキーを設定してください。

    // Find panel key bindings
  { "keys": ["command+enter"], "command": "find_next", "context":
    [{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}]
  },
  // Replace panel key bindings
  { "keys": ["command+enter"], "command": "find_next", "context":
    [{"key": "panel", "operand": "replace"}, {"key": "panel_has_focus"}]
  },
  // Incremental find panel key bindings
  { "keys": ["command+enter"], "command": "hide_panel", "context":
    [{"key": "panel", "operand": "incremental_find"}, {"key": "panel_has_focus"}]
  }