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

More than 1 year has passed since last update.

【ちょっと便利な小技_part 9】自作スニペット+α編

Last updated at Posted at 2023-09-11

今回はSnippetを自作するときに知っていて損はない知識を紹介します。
簡単な内容となっているので是非試してみてください。

前提

この記事は下記の記事を既に見ている,
またはSnippetについての知識が既にある前提で話を進めます。

+αの知識

下記の自作したSnippetに記載されている、『$~』の役割について説明いたします。

dart.json
"TextTmp": {
		"prefix": "texttmp",
		"body": [
			"Text(",
			"  \"$1\",",
			"  style: TextStyle(",
			"    color:$2,",
			"    fontSize: $3,",
			"    fontWeight: $4,",
			"  ),",
			")"
		],
		"description": "TextTmp"
	}

『$~』の役割について

実際に上記のSnippetを使用してみると下記のように表示されます。
見てわかるようにSnippetを使用したタイミングで初期のカーソル位置が『$1』と入力していたところになっています。
他にも『$2』,『$3』と入力していたところには、縦の線が入っています。
『$1』のところの入力が終わった後、タブキーを押すことによって『$2』のところへカーソルが移動されます。
Snippet作成時に任意の入力が必要となる場所に『$~』と入れることによって、楽に入力を行うことができます。
スクリーンショット 2023-09-11 2.33.27.png

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