6
6

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 3 years have passed since last update.

VScode 競プロ用スニペット(C++)

Last updated at Posted at 2020-02-25

#競技プログラミング用VScodeスニペット
CodeForces,AtCoderに参加するときによく使うスニペットを置いておきます。
(ちょくちょくどう書くのか忘れることがあったので...)

{
	// Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
	// same ids are connected.
	// Example:
	"Print to console": {
		"prefix": "cpptemplate",
		"body": [
			"/**",
			"*    author:  Dooloper",
			"*    created: $CURRENT_DATE.$CURRENT_MONTH.$CURRENT_YEAR $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",       
			"**/",
			"",
			"#include <bits/stdc++.h>",
			"",
			"using namespace std;",
			"",
			"int main() {",
			"	cin.tie(0);",
			"	ios_base::sync_with_stdio(false);",
			"",
			"	return 0;",
			"}"
		],
		"description": "cpp_template"
	}
}

(一応設定方法も書いておきます!※言語設定が英語ですが日本語でも全く同じです)

VScode部分
File->Preferences->UserSnippets->cpp

snipet5.gif

上のように設定して、C++用のファイルを作成します。
そこで、prefix部分に書かれた文字を打ち込むとスニペットが呼び出されます。

snipet3.gif

個人的には、時間と日付部分を忘れてしまう部分なので、スニペットを用意できると楽です。
完成は以下みたいな感じ...

VScodeスニペット.PNG

もっと、様々な部品を細かく設定できるので結構楽しいです!
C++だけでなく、様々な言語で活用できるので是非

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?