vscode代码片段

82 阅读1分钟

记录自己的用户代码片段, 提高开发效率 记录自己的用户代码片段, 提高开发效率 记录自己的用户代码片段, 提高开发效率

ts

{
  // Place your snippets for typescript 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:
  "@property": {
    "prefix": "@",
    "body": [
      "@property(cc.Node)",
      "$1Node: cc.Node = null"
    ],
    "description": "Log output to console"
  },
  "@property(cc.Label)": {
    "prefix": "@l",
    "body": [
      "@property(cc.Label)",
      "$1Label: cc.Label = null"
    ],
    "description": "Log output to console"
  },
  "@property(cc.Prefab)": {
    "prefix": "@p",
    "body": [
      "@property(cc.Prefab)",
      "$1Prefab: cc.Prefab = null"
    ],
    "description": "Log output to console"
  },
  "Print to console": {
    "prefix": "cl",
    "body": ["console.log('$1', $1);"],
    "description": "Log output to console"
  },
  "Print to console1": {
    "prefix": "c",
    "body": ["console.log('$1');"],
    "description": "Log output to console"
  },
  "console.warn": {
    "prefix": "cw",
    "body": ["console.warn('$1')"],
    "description": "console.warn"
  },
  "import ~tsd": {
    "prefix": "tsd",
    "body": ["import { $1 } from '~tsd'"],
    "description": "import ~tsd"
  },
  "generic promise": {
    "prefix": "pt",
    "body": ["Promise<$1>"],
    "description": "generic promise"
  },
  "export declare": {
    "prefix": "ed",
    "body": ["export declare"],
    "description": "export declare"
  },
  "export function": {
    "prefix": "ef",
    "body": ["export function"],
    "description": "export function"
  },
  "export const": {
    "prefix": "ec",
    "body": ["export const"],
    "description": "export const"
  },
  "export * from": {
    "prefix": "e*",
    "body": ["export * from '$1'"],
    "description": "export * from"
  },
  "import {} from": {
    "prefix": "im",
    "body": ["import { $1 } from '~/common$2'"],
    "description": "import {} from"
  },
  "declare type": {
    "prefix": "dt",
    "body": ["declare type"],
    "description": "declare type"
  },
  "description": {
    "prefix": "/",
    "body": ["/** $1 */"],
    "description": "description"
  },
  "try catch": {
    "prefix": "tc",
    "body": [
      "try {",
      "  $1",
      "} catch (err) {",
      "  console.log('err', err)",
      "}"
    ],
    "description": "try catch"
  },
  "@param": {
    "prefix": "@p",
    "body": "@param {$1}  - ",
    "description": "@param"
  },
  ".then": {
  "prefix": ".t",
  "body": [
    ".then((res) => {",
    "  console.log('res', res)",
    "  $1",
    "})",
    ".catch((err) => {",
    "  console.log('err', err)",
    "})"
  ]
  }
}


js

{
  // Place your snippets for typescript 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"
  },
  "console.warn": {
    "prefix": "cw",
    "body": ["console.warn('$1')"],
    "description": "console.warn"
  },
  "import ~tsd": {
    "prefix": "tsd",
    "body": ["import { $1 } from '~tsd'"],
    "description": "import ~tsd"
  },
  "generic promise": {
    "prefix": "pt",
    "body": ["Promise<$1>"],
    "description": "generic promise"
  },
  "export declare": {
    "prefix": "ed",
    "body": ["export declare"],
    "description": "export declare"
  },
  "export function": {
    "prefix": "ef",
    "body": ["export function"],
    "description": "export function"
  },
  "export const": {
    "prefix": "ec",
    "body": ["export const"],
    "description": "export const"
  },
  "export * from": {
    "prefix": "e*",
    "body": ["export * from '$1'"],
    "description": "export * from"
  },
  "import {} from": {
    "prefix": "im",
    "body": ["import { $1 } from '~/common$2'"],
    "description": "import {} from"
  },
  "declare type": {
    "prefix": "dt",
    "body": ["declare type"],
    "description": "declare type"
  },
  "description": {
    "prefix": "/",
    "body": ["/** $1 */"],
    "description": "description"
  }
}

vue

{
	// Place your snippets for vue 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": "v",
		"body": [
			"<template>",
			"    <div></div>",
			"</template>",
			"",
			"<script>",
			"export default {",
			"    data() {},",
			"    mounted() {},",
			"};",
			"</script>",
			"",
			"<style scoped lang=\"stylus\"></style>",
		],
		"description": "Log output to console"
	}
}