vscode配置用户代码片段(快捷键自定义代码模板)

vscode 配置 用户代码片段入口如下
在这里插入图片描述
分享两个我配置的
1、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": "vue",
		"body": [
			//"<!-- $1 -->",
			"<template>",
			"  <div class='$2'>城南花已开,老程已不在;</div>",
			"</template>",
			"",
			"<script>",
			// "//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)",
			// "//例如:import 《组件名称》 from '《组件路径》';",
			"export default {",
			// "// 组件名字"
			"  name: '',",
			// "//import引入的组件需要注入到对象中才能使用",
			"  components: {},",
			// "//接收父组件传来的变量",
			"  props: {},",
			"  data() {",
			// "//这里存放数据",
			"    return {}",
			"  },",
			// "//监听属性 类似于data概念",
			"  computed: {},",
			// "//监控data中的数据变化",
			"  watch: {},",
			// "//生命周期 - 创建完成(可以访问当前this实例)",
			"  created() {},",
			// "//生命周期 - 挂载完成(可以访问DOM元素)",
			"  mounted() {},",
			// "//生命周期 - 创建之前",
			// "beforeCreate() {",
			// "",
			// "},",
			// "//生命周期 - 挂载之前",
			// "beforeMount() {",
			// "",
			// "},",
			// "//生命周期 - 更新之前",
			// "beforeUpdate() {",
			// "",
			// "}, ",
			// "//生命周期 - 更新之后",
			// "updated() {",
			// "",
			// "}, ",
			// "//生命周期 - 销毁之前",
			// "beforeDestroy() {",
			// "",
			// "},",
			// "//生命周期 - 销毁完成",
			// "destroyed() {",
			// "",
			// "},",
			// "//如果页面有keep-alive缓存功能,这个函数会触发",
			// "activated() {",
			// "",
			// "},",
			// "//方法集合",
			"  methods: {}",
			"}",
			"</script>",
			"<style lang='scss' scoped>",
			// "//@import url($3); 引入公共css类",
			// "$4",
			"</style>",
			""
		],
		"description": "Log output to console"
	}
}

2、axios

{
  // Place your 全局 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": "axios",
    "body": [
      // 		"console.log('$1');",
      // 		"$2"
      "let params={}",
      "axios",
      ".post('', params)",
      ".then((res) => {",
      "console.log('res', res)",
      "})",
      ".catch((err) => {",
      "console.log(err)",
      " })"
    ],
    "description": "Log output to console"
  }
}

3、Promise

{
  // Place your 全局 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": "Promise",
    "body": [
      // 		"console.log('$1');",
      // 		"$2"
      "return new Promise((resolve, reject) => {",
      "// resolve()",
      "reject()",
      "})"
    ],
    "description": "Log output to console"
  }
}

在 casking 的 vscode 设置:

{
  "open-in-browser.default": "Chrome",
  "todo-tree.highlights.enabled": false,
  "background.enabled": false,
  "vsicons.dontShowNewVersionMessage": true,
  "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
  "[vue]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "files.eol": "\n",
  "explorer.confirmDelete": false,
  "[html]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "eslint.autoFixOnSave": true,
  "eslint.workingDirectories": [],
  "eslint.runtime": "",
  "eslint.nodePath": "",
  "eslint.validate": [],
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "vetur.validation.template": false,
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "vetur.validation.interpolation": false,
  "explorer.confirmDragAndDrop": false,
  "fileheader.customMade": {
    // 头部注释
    "Author": "chengsl",
    "Date": "Do not edit",
    "LastEditors": "chengsl",
    "LastEditTime": "Do not edit",
    "Description": "file content"
  },
  "fileheader.cursorMode": {
    // 头部注释
    "description": "",
    "param": "params",
    "return": ""
  },
  "fileheader.configObj": {
    "autoAdd": true, // 默认开启自动添加头部注释,当文件没有设置头部注释时保存会自动添加
    "autoAlready": true, // 默认开启
    "prohibitAutoAdd": ["json", "md", "scss", "vue"], // 禁止.json .md文件,自动添加头部注释
    "wideSame": false, // 设置为true开启
    "wideNum": 13 // 字段长度 默认为13
  },
  "prettier.arrowParens": "avoid",
  "prettier.semi": false,
  "prettier.singleQuote": true,
  "security.workspace.trust.untrustedFiles": "open",
  "editor.suggestSelection": "first",
  "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
  "editor.unicodeHighlight.allowedCharacters": {
    ":": true,
    " ": true
  },
  "files.associations": {
    "*.cjson": "jsonc",
    "*.wxss": "css",
    "*.wxs": "javascript",
    "*.log": "log"
  },
  "emmet.includeLanguages": {
    "wxml": "html"
  },
  "minapp-vscode.disableAutoConfig": true,

  // TODO
  "todo-tree.tree.showScanModeButton": false,
  "todohighlight.keywords": [
    {
      "text": "// TODO",
      "color": "#fff",
      "backgroundColor": "#FFBD2A"
    },
    {
      "text": "<!-- TODO",
      "color": "#fff",
      "backgroundColor": "#FFBD2A"
    },
    {
      "text": "* TODO",
      "color": "#fff",
      "backgroundColor": "#FFBD2A"
    },
    {
      "text": "40@remarks",
      "color": "#fff",
      // "backgroundColor": "#3BA776"
      "backgroundColor": "#009900"
    },
    {
      "text": "shilin@say",
      "color": "#fff",
      // "backgroundColor": "#3BA776"
      "backgroundColor": "#009900"
    },
    {
      "text": "40@test",
      "color": "#fff",
      // "backgroundColor": "#3BA776"
      "backgroundColor": "#FFBD2A"
    },
    {
      "text": "40@warn",
      "color": "#fff",
      "backgroundColor": "#CB3939"
    }
  ],
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "editor.tabSize": 2,
  "editor.unicodeHighlight.allowedLocales": {
    "zh-hans": true,
    "ja": true,
    "zh-hant": true
  },
  "workbench.editor.untitled.hint": "hidden",
  "prettier.jsxSingleQuote": true,
  "[nginx]": {
    "editor.defaultFormatter": "ahmadalli.vscode-nginx-conf"
  },
  "pathAlias.aliasMap": {
    "@": "${cwd}/src"
  },
  "vscode-office.openOutline": false,
  "[css]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "editor.wordWrapColumn": 135,
  "[scss]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "minapp-vscode.prettier": {
    "parser": "html",
    "useTabs": false,
    "tabWidth": 2,
    "printWidth": 100,
    "singleQuote": false
  },
  "lsby_gitee_vscode_plugin.personal_access_tokens": "3989a0245806ac55ef7ed129e01b68ff",
  "git.autofetch": true,
  "update.enableWindowsBackgroundUpdates": false,
  "editor.unicodeHighlight.invisibleCharacters": false,
  "editor.unicodeHighlight.ambiguousCharacters": false
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

#老程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值