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

【Zed】Snippetの設定方法

Posted at

設定ファイルを作成する

コマンドパレットでsnippets: configure snippetsを実行します。

スクリーンショット 2025-01-28 22.52.58.png

スニペットを登録する言語を選択します。

スクリーンショット 2025-01-28 22.54.30.png

TSXを選択した場合には~/.config/zed/snippets/tsx.jsonが開きます。

スニペットを記述する

tsx.jsonにスニペットを記述します。

tsx.json
{
  "React Client Component": {
    "prefix": "rcc",
    "body": [
      "${1:'use client'}",
      "",
      "type ${2:Props} = {",
      "\t$3",
      "}",
      "",
      "export function ${4:ClientComponent}({$5}: ${2:Props}) {",
      "\t$6",
      "\treturn (",
      "\t\t$0",
      "\t)",
      "}"
    ],
    "description": "React Client Component"
  },
  "Log to the console": {
    "prefix": "log",
    "body": ["console.${2|log,error,table|}($1)", "$0"],
    "description": "Log to the console"
  }
}

  • $1,$2...$0:Tabを押下すると1,2...0の順番でカーソルが移動
  • ${4:ClientComponent}:デフォルト値
  • console.${2|log,error,table|}||で括られた値から選択

動作

画面収録 2025-01-28 23.40.11.gif

画面収録 2025-01-28 23.40.41.gif

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?