0
0

【VSCode】簡単にスニペットを作成する方法

Last updated at Posted at 2024-06-22

Snippet Generatorという拡張機能を使用すると簡単にスニペットを作成できます。

スクリーンショット 2024-06-22 23.57.06.png

スニペットを作成したいコードを選択してコマンドパレットからGenerate Snippetを実行し、必要事項を入力するとスニペットを設定するためのオブジェクトがクリップボードに保存されます。

Snippets Configure User Snippetsを実行します。

スクリーンショット 2024-06-23 0.01.28.png

開いた設定ファイルにクリップボードの内容を貼り付けるとスニペットを使用できるようになります。

以下のようにショートカットキーを設定するとGenerate Snippetの必要事項を入力した後にSnippets Configure User Snippetsが実行されファイル選択できるようになり、より簡単に作成できます。

keybindings.json
{
  {
    "key": "任意のキー",
    "command": "runCommands",
    "args": {
      "commands": [
        "snippet-generator.generate-snippet",
        "workbench.action.openSnippets"
      ]
    }
  }
}

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