1
0

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で漢字化エスペラント入力を快適にする方法

1
Last updated at Posted at 2025-09-30
https://drive.google.com/file/d/1s9K7grkGcc6E3WAEJ_HXBAPIw_cJhdLg/view?usp=sharing 👈エスペラント語根-漢字スニペット

↓下記の記事も適宜参考にしてください。

問題

VSCodeのスニペット機能で漢字化エスペラントを入力する際、以下の問題が発生していました:

  1. 漢字の直後にスニペットprefixを入力しても候補が表示されない

    • 例:更bon と入力しても bon のスニペット候補が出ない
    • VSCodeが 更bon を一つの単語として認識してしまう
  2. 不要な長文の予測候補が常に表示される

    • 過去の文章から自動補完される

解決策の概要

専用の言語モード(拡張機能)を作成し、以下を実現:

  • 漢字とアルファベットを別々の単語として認識
  • 専用ファイル拡張子(.ke.txt)を使用
  • 不要な補完機能を無効化

手順

1. 拡張機能フォルダの作成

エクスプローラーで以下のパスを開く:

%USERPROFILE%\.vscode\extensions

kanji-esperanto という名前のフォルダを作成。

2. 必要なファイルを作成

kanji-esperanto フォルダ内に以下の2ファイルを作成:

package.json

{
  "name": "kanji-esperanto",
  "displayName": "Kanji Esperanto Helper",
  "description": "Enables snippet completion after kanji",
  "version": "0.1.0",
  "publisher": "local",
  "engines": {
    "vscode": "^1.60.0"
  },
  "contributes": {
    "languages": [{
      "id": "kanji-esperanto",
      "aliases": ["Kanji Esperanto"],
      "extensions": [".ke.txt", ".ke"],
      "configuration": "./language-configuration.json"
    }]
  }
}

language-configuration.json

{
  "wordPattern": "([a-zA-Z]+)|([\\u4e00-\\u9fff]+)"
}

この正規表現により:

  • [a-zA-Z]+ : アルファベット文字列
  • [\\u4e00-\\u9fff]+ : 漢字

が別々の単語として認識されます。

3. VSCodeの設定を追加

settings.json に以下を追加:

{
  "editor.suggest.matchOnWordStartOnly": false,
  "editor.quickSuggestions": {
    "other": true,
    "comments": false,
    "strings": false
  },
  "editor.quickSuggestionsDelay": 10,
  "editor.suggest.showSnippets": true,
  "editor.snippetSuggestions": "top",
  "editor.suggest.snippetsPreventQuickSuggestions": false,
  "editor.suggestOnTriggerCharacters": true,
  "editor.suggest.filterGraceful": false,
  "editor.suggest.showWords": false,
  
  "[kanji-esperanto]": {
    "editor.wordBasedSuggestions": "off",
    "editor.quickSuggestions": {
      "other": true,
      "comments": true,
      "strings": true
    },
    "editor.inlineSuggest.enabled": false,
    "editor.suggest.preview": false,
    "github.copilot.enable": {
      "*": false
    }
  }
}

重要な設定:

  • editor.suggest.matchOnWordStartOnly: false - 語中一致も許可
  • editor.wordBasedSuggestions: "off" - 文書内の単語候補を無効化
  • editor.inlineSuggest.enabled: false - インライン補完を無効化
  • github.copilot.enable: false - Copilotを無効化(kanji-esperantoのみ)

4. スニペットを作成

  1. Ctrl+Shift+P → "Snippets: Configure User Snippets"
  2. "kanji-esperanto.json (kanji-esperanto)" を選択
  3. スニペットを定義:
{
  "li to 他": {"prefix": "li", "body": "他"},
  "mi to 我": {"prefix": "mi", "body": "我"},
  "bon to 好": {"prefix": "bon", "body": "好"}
}

5. VSCodeを再起動

完全にVSCodeを閉じて再起動。

6. 使用方法

  1. ファイルの拡張子を .ke.txt にする

    • 例:try.txttry.ke.txt
  2. ファイルを開くと、右下の言語モードが自動的に「Kanji Esperanto」になる

  3. 入力テスト:

    更bon ← 「好」のスニペット候補が自動表示される
    

ファイル構成

最終的なフォルダ構成:

C:\Users\[ユーザー名]\.vscode\extensions\kanji-esperanto\
├── package.json
└── language-configuration.json

トラブルシューティング

拡張機能が認識されない場合

開発者ツールでエラー確認:

  1. Ctrl+Shift+P → "Developer: Toggle Developer Tools"
  2. Consoleタブで赤いエラーを確認

言語モードが切り替わらない場合

手動で切り替え:

  1. 画面右下の言語モード表示をクリック
  2. "Kanji Esperanto" を選択

スニペットが表示されない場合

  1. kanji-esperanto.json が正しく作成されているか確認
  2. VSCodeを再起動

まとめ

この方法により:

  • ✅ 漢字の直後でもスニペット候補が自動表示
  • ✅ 不要な長文予測が表示されない
  • ✅ 快適な漢字化エスペラント入力環境を実現

.ke.txt 拡張子を使うだけで、自動的に最適な設定が適用されます。

1
0
1

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?