vscode snippet ๋ง๋ค๊ธฐ
console.log๋ก ๋ก๊ทธ๋ฅผ ์ฐ๋๋ค๊ฑฐ๋ ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ค๋ ํจ์ํ ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ค ๋์ ๊ตฌ์กฐ๋ฅผ ๋ง๋ค๋๋ผ๋์ง ๊ธฐ๋ณธ์ ์ผ๋ก ๋ง๋ค์ด์ผํ๋ ๋ผ๋๋ฅผ ์์ฑํ๋ ๋ถ๋ถ์ ์ด์ ๋ ์์ ํ ์ตํ์ ธ์ snippet์ ์ฌ์ฉํ์ฌ ์ฌ์ฉํ๊ณ ์์๋ค.
๐๐ป ๊ฒฐ๋ก ์ ์ผ๋ก ๋ฆฌ์กํธ๋ฅผ ์ฌ์ฉ์ ์ค, ํจ์ ํํ์ ๋ฑ ์ค์ ์์ด ์ค๋ํซ์ ์ฌ์ฉํ๊ธฐ ์ํ๋ค๋ฉด ์๋ extension(ES7+ React/Redux/React-Native snippets)์ ๋ค์ด๋ฐ์ ์ฌ์ฉํ์๊ธธ ๊ถ์ฅํ๋ค.
ES7+ React/Redux/React-Native snippets
rafce๋ผ๋ ์ค๋ํซ์ ํจ์ ํํ์์ ๋น ๋ฅด๊ฒ ์์ฑํด์ฃผ์ด ์ฝ๋์์ฐ์ฑ์ด ๋น ๋ฅด๊ฒ ์ฆ๊ฐํ๋ค.
๐๐ป ๋ง์ฝ ๋ค๋ฅธ ์ค๋ํซ์ ์ค์ ํ๊ณ ์ถ๊ฑฐ๋, ์ค๋ํซ ๋จ์ถํค๋ฅผ ๋ฐ๊พธ๊ณ ์ถ๋ค๋ฉด ๋ ์๋์ ์ค์ ๋ฐฉ๋ฒ์ ์์ฑํด๋จ๋ค.
Snippet ์ฌ์ฉ์ํ
๋งฅ๋ถ๊ธฐ์ค ๋จ์ถํค command+p ๋๋ฅด๊ณ global-snippet-js.code-snippets ํ์ผ ํด๋ฆญํ๊ธฐ
์ด์ ํ์ผ์์ ์ค๋ํซ์ ์ค์ ํ๋ฉด ๋๋ค. console.log๋ฅผ cl์ด๋ผ๋ ์ค๋ํซ์ผ๋ก ์ค์ ํ๋ ๊ฒ์ ๋ด๋ณด์.
"console.log": {
"prefix": "cl",
"body": ["console.log('$1');", "$2"],
"description": "Log output to console"
},
prefix : ๋จ์ถํค
body : ์ค์ ์ฝ๋
description : ์ค๋ํซ ์ค๋ช
ํ ์คํธ ์ปค์
$1, $2์ ๊ฐ์ ๊ฒ๋ค์ ํ ์คํธ ์ปค์ ์์น ์ด๋ค.
${์์}๋ก ์๋ํ๋ค. ๋ฐ๋ผ์ cl์ ์ ๋ ฅํ๊ณ ์ํฐ๋ฅผ ๋๋ ์ ๋ ()์ฌ์ด์ ์ปค์๊ฐ ์์นํ๊ฒ ๋๋ค.
์ค๋ํซ ๋ณ์
๋๋ ์๋์ ๊ฐ์ด styled-components๊ฐ ๋ค์ด๊ฐ ํจ์ํ์ปดํฌ๋ํธ ์ฝ๋์ ๋ผ๋๋ฅผ ๋ง๋ค๊ณ ์ถ์๋ค.
import { styled } from "styled-components";
function Title() {
return <div></div>
}
export default Title;
๊ทธ๋ฌ๊ธฐ ์ํด์ ํ์ผ๋ช ์ ๊ฐ์ง๊ณ ์์ผํ๋๋ฐ ์ด๋ ์ค๋ํซ ๋ณ์๋ก ๊ฐ์ ธ์ฌ ์ ์๋ค.
์ค๋ํซ ๋ณ์๋ค์ ์๋์์ ํ์ธํ ์ ์๊ณ , ํ์ผ๋ช ์ ${TM_FILENAME_BASE} ์ ์ฌ์ฉํ๋ฉด ๋๋ค.
https://code.visualstudio.com/docs/editor/userdefinedsnippets#_variables
Snippets in Visual Studio Code
It is easy to add code snippets to Visual Studio Code both for your own use or to share with others on the public Extension Marketplace. TextMate .tmSnippets files are supported.
code.visualstudio.com
๊ทธ๋์ ๋ง๋ ์ค๋ํซ ์ฝ๋๋ ์๋์ ๊ฐ๋ค.
"Component with stytled-components": {
"prefix": "rfs",
"body": [
"import { styled } from \"styled-components\";",
"",
"function ${TM_FILENAME_BASE}() {",
" return <div>${1}</div>",
"}",
"",
"export default ${TM_FILENAME_BASE};"
],
"description": "Component with stytled-components"
},
rfs๋ฅผ ๋๋ฅด๋ฉด ์์๊ฒ ํ์ผ๋ช ์ ๋ฐ๋ฅธ ์ฝ๋๊ฐ ๋ฐ๊ฒ์ด๋ค! ๐ฅด