Utils

VS Code user snippet

Louiey 2021. 8. 2. 16:11

VS code 에서 user snippet 추가하기

 

1. File -> Preference -> User Snippet

2. 저장하고자 하는 이름.json 을 입력 후 엔터

3. json file 에서 아래처럼 필요한 snippet 을 설정하여 입력

4, 저장 후 사용하면 추가된 snippet 이 동작한다.

 

 

{
	// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
	// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
	// is left empty or omitted, the snippet gets applied to all languages. 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:
	"comment by louiey": {
	 	"scope": "c,cpp,cs,h,hpp,javascript,typescript",
	 	"prefix": "//-",
	 	"body": [
	 				"// louiey, $CURRENT_YEAR.$CURRENT_MONTH.$CURRENT_DATE. $2"
	 	],
	 	"description": "// louiey, comment"
	},

	"Add doxygen function": {
    	"scope": "c,cpp,cs,h,hpp,javascript,typescript",
		"prefix": "//-df", 
		"body": [ 
					"/*!" 
					" @brief "
					" @param[in] " 
					" @param[out] " 
					" @return " 
					"*/" 
				], 
		"description": "Doxygen function tags" 
	},
	
	"File Header Comment": { 
    	"scope": "c,cpp,cs,h,hpp,javascript,typescript",
		"prefix": "//-fh", 
		"body": [ 
					"/*" 
					" * @Author : Louie Yang"
					" * @Date: $CURRENT_YEAR.$CURRENT_MONTH.$CURRENT_DATE."
					" * @Description: "
					" * @Last Modified time: $CURRENT_YEAR.$CURRENT_MONTH.$CURRENT_DATE."
					" * @History: "
					"				"
					" */"
				], 
		"description": "File header comments" 
	}
}

VS code for user snippet