Skip to content

Instantly share code, notes, and snippets.

@karenying
Created July 25, 2021 01:59
Show Gist options
  • Save karenying/6ac8e198ef756c7cb5fd65bddf521811 to your computer and use it in GitHub Desktop.
Save karenying/6ac8e198ef756c7cb5fd65bddf521811 to your computer and use it in GitHub Desktop.
global.code-snippets
{
// 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:
// "Print to console": {
// "scope": "javascript,typescript",
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Print to console": {
"scope": "javascript, typescript, javascriptreact, typescriptreact",
"prefix": "log",
"body": ["console.log('$1');", "$2"],
"description": "Log output to console"
},
"useEffect hook": {
"scope": "javascript, typescript, javascriptreact, typescriptreact",
"prefix": "useE",
"body": ["useEffect(() => {", "\t$1", "})"],
"description": "useEffect hook"
},
"useState hook": {
"scope": "javascript, typescript, javascriptreact, typescriptreact",
"prefix": "useS",
"body": ["const [$1, $2] = useState($3);$0"],
"description": "useState hook"
},
"useCallback hook": {
"scope": "javascript, typescript, javascriptreact, typescriptreact",
"prefix": "useC",
"body": ["useCallback(() => {", "\t$1", "}, [$2])"],
"description": "useCallback hook"
},
"react fragment": {
"scope": "javascript, typescript, javascriptreact, typescriptreact",
"prefix": "frag",
"body": ["<>", "\t$1", "</>"],
"description": "React fragment"
},
"css flex center": {
"scope": "css, scss",
"prefix": "flex center",
"body": [
"display: flex;",
"align-items: center;",
"justify-content: center;"
],
"description": "Flex center"
},
"emotion": {
"scope": "javascript, typescript, javascriptreact, typescriptreact",
"prefix": "emo",
"body": ["export const $1 = styled.div`\n\t$2\n`;"],
"description": "Emotion div"
},
"styled": {
"scope": "javascript, typescript, javascriptreact, typescriptreact",
"prefix": "sty",
"body": ["import styled from \"@emotion/styled\";"],
"description": "Import styled"
},
"react functional component": {
"scope": "javascript, typescript, javascriptreact, typescriptreact",
"prefix": "fc",
"body": [
"import React, { FC } from 'react';\n\nconst $TM_FILENAME_BASE$1: FC = () => {",
"\t$2",
"\treturn (",
"",
"\t)",
"}\n\nexport default $TM_FILENAME_BASE;"
],
"description": "React functional component"
},
"react functional component w/ props": {
"scope": "javascript, typescript, javascriptreact, typescriptreact",
"prefix": "fcp",
"body": [
"import React, { FC } from 'react';\n\ninterface Props {$1}\n\nconst $TM_FILENAME_BASE$2: FC<Props> = ({$3}) => {",
"\t$2",
"\treturn (",
"",
"\t)",
"}\n\nexport default $TM_FILENAME_BASE;"
],
"description": "React functional component with props"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment