VSCode User Snippet "console.log(), alert()"
자바스크립트 사용시 console.log 숨쉬듯이 쓰기때문에
파일형태가 아니라 VSCode 프로그램에 내장되어있는 기본설정을 통해 고정적으로 입력시켜서 사용하면 편하다.
현재 [ cl + 탭키 ] 입력시 class 가 표기되는데 class 보다는 console.log 사용량이 압도적으로 많으므로
[ cl + 탭키 ] 입력시 console.log( 커서위치 ); 가 되도록 설정을 변경(추가) 해보겠다.
2020.07.10
- 내용추가 : alert, return false, return true
파일 > 기본 설정 > 사용자 코드 조각
javascript.json 파일을 찾아서 선택
아래의 코드를 붙여넣고 저장
{
// Place your snippets for javascript 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": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Print to console": {
"prefix": "cl",
"body": [
"console.log($1);",
],
"description": "Log output to console"
},
"Print to Alert": {
"prefix": "al",
"body": [
"alert(`$1`);",
],
"description": "alert"
},
"return false": {
"prefix": "rf",
"body": [
"return false;",
],
"description": "return false"
},
"return true": {
"prefix": "rt",
"body": [
"return true;",
],
"description": "return true"
}
}
* 붙여넣는 코드의 형태가 깨진다면 아래의 소스를 복사 붙여넣기
{
// Place your snippets for javascript 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": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Print to console": {
"prefix": "cl",
"body": [
"console.log($1);",
],
"description": "Log output to console"
},
"Print to Alert": {
"prefix": "al",
"body": [
"alert(`$1`);",
],
"description": "alert"
},
"return false": {
"prefix": "rf",
"body": [
"return false;",
],
"description": "return false"
},
"return true": {
"prefix": "rt",
"body": [
"return true;",
],
"description": "return true"
}
}