1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VSCodeのキーバインド設定の追加( "VSCodeで漢字化エスペラント入力を快適にする方法" への追加記事)

Posted at

↑上記への追加記事

概要

Kanji Esperanto モードでの入力をさらに快適にするため、キーバインドをカスタマイズします。これにより、削除操作後も自動的にスニペット候補が再表示されるようになります。

実現する機能

Backspace/Delete後も候補が自動再表示
候補表示中は通常の削除動作
Ctrl+Spaceでいつでも候補を強制表示

設定手順

1. keybindings.json を開く

  1. Ctrl+Shift+P を押す
  2. 「Preferences: Open Keyboard Shortcuts (JSON)」と入力して選択

2. 設定を追加

開いたファイルに、以下の設定を追加します:

[
  // ========================================
  // 🔥 Kanji Esperanto 専用設定
  // ========================================
  
  // 【Backspace】候補未表示時:削除 → 候補を再表示
  {
    "key": "backspace",
    "command": "runCommands",
    "args": {
      "commands": [
        "deleteLeft",
        "editor.action.triggerSuggest"
      ]
    },
    "when": "editorTextFocus && !editorReadonly && !suggestWidgetVisible && editorLangId == 'kanji-esperanto'"
  },
  
  // 【Backspace】候補表示中:通常の削除のみ(候補は自動更新される)
  {
    "key": "backspace",
    "command": "deleteLeft",
    "when": "editorTextFocus && !editorReadonly && suggestWidgetVisible && editorLangId == 'kanji-esperanto'"
  },
  
  // 【Delete】候補未表示時:削除 → 候補を再表示
  {
    "key": "delete",
    "command": "runCommands",
    "args": {
      "commands": [
        "deleteRight",
        "editor.action.triggerSuggest"
      ]
    },
    "when": "editorTextFocus && !editorReadonly && !suggestWidgetVisible && editorLangId == 'kanji-esperanto'"
  },
  
  // 【Delete】候補表示中:通常の削除のみ
  {
    "key": "delete",
    "command": "deleteRight",
    "when": "editorTextFocus && !editorReadonly && suggestWidgetVisible && editorLangId == 'kanji-esperanto'"
  },
  
  // 【Ctrl+Space】いつでも候補を表示(強制トリガー)
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorTextFocus && editorLangId == 'kanji-esperanto'"
  },
  
  // ========================================
  // 📝 PlainText モード(既存設定を維持)
  // ========================================
  
  {
    "key": "backspace",
    "command": "runCommands",
    "args": {
      "commands": [
        "deleteLeft",
        "editor.action.triggerSuggest"
      ]
    },
    "when": "editorTextFocus && editorLangId == 'plaintext' && !suggestWidgetVisible"
  }
]

3. 保存して完了

Ctrl+S で保存します。設定は即座に反映されます。

各設定の詳細説明

Backspace の動作

状況 動作
候補が表示されていない時 1文字削除 → 自動的に候補を再表示
候補が表示されている時 1文字削除のみ(候補は自動更新)

Delete の動作

状況 動作
候補が表示されていない時 カーソル右の1文字削除 → 自動的に候補を再表示
候補が表示されている時 カーソル右の1文字削除のみ

Ctrl+Space

いつでも強制的に候補リストを表示します。候補が消えてしまった時に便利です。

使用例

ケース1:入力ミスの修正

入力: 更bonn
     ↓ Backspace を1回押す
結果: 更bon(候補リストが自動表示される)
     ↓ Enterで確定
結果: 更好

ケース2:候補の再表示

入力: 更bon
     ↓ 候補が消えてしまった
     ↓ Ctrl+Space を押す
結果: 候補リストが再表示される

when条件の説明

キーバインドが適用される条件を細かく制御しています:

条件 意味
editorTextFocus エディタにフォーカスがある
!editorReadonly 読み取り専用でない
suggestWidgetVisible 候補リストが表示されている
!suggestWidgetVisible 候補リストが表示されていない
editorLangId == 'kanji-esperanto' Kanji Esperantoモードのファイルのみ

これにより、.ke.txt ファイルでのみこの特殊な動作が有効になり、他のファイルには影響しません。

トラブルシューティング

キーバインドが動作しない場合

  1. keybindings.json の構文を確認

    • JSONの構文エラーがないか確認
    • VSCode右下にエラー表示が出ていないか確認
  2. 言語モードを確認

    • ファイルが「Kanji Esperanto」モードになっているか確認(右下の表示)
    • .ke.txt 拡張子になっているか確認
  3. VSCodeを再起動

    • 完全に閉じて再度開く

他のキーバインドと競合する場合

既存のキーバインドを確認:

  1. Ctrl+Shift+P → 「Preferences: Open Keyboard Shortcuts」
  2. 検索ボックスに「backspace」や「delete」と入力
  3. 競合している設定を無効化

まとめ

この設定により、Kanji Esperanto モードでの入力がさらに快適になります:

  • ✅ 削除後も候補が自動で出るので、入力の流れが途切れない
  • .ke.txt ファイル専用なので、他のファイルに影響なし
  • ✅ Ctrl+Spaceで困った時の脱出も可能

これで漢字化エスペラント入力環境の構築は完了です!Happy coding! 🎉

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?