IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> VsCode自定义模板,用模板记笔记?! -> 正文阅读

[开发工具]VsCode自定义模板,用模板记笔记?!

起因

其实接触模板已经很久了。但我一直没怎么重视。但最近在乱学一通后发现。比起传统的笔记来说。用模板当学习笔记真是有很大优势。他不要求你完全记住。复习之前学过的知识也很方便。适合快速学习开发
下面我就举个例子

工欲善其事,必先利其器。

我们先写模板的模板
怎么创建模板我就略过了,就是选设置,再选用户代码片段。具体参考vscode自定义模板
因为vscode配置都是json文件,就创建json文件的模板

json.json

	"tm-selected-text": {
		"prefix": "tm-selected-text",
		"body": "\\$TM_SELECTED_TEXT",
		"description": "当前选中的文本或空字符串"
	},
	"tm-current-line": {
		"prefix": "tm-current-line",
		"body": "\\$TM_CURRENT_LINE",
		"description": "当前行的内容"
	},
	"tm-current-word": {
		"prefix": "tm-current-word",
		"body": "\\$TM_CURRENT_WORD",
		"description": "光标下单词的内容或空字符串"
	},
	"tm-line-index": {
		"prefix": "tm-line-index",
		"body": "\\$TM_LINE_INDEX",
		"description": "从0开始的行号"
	},
	"tm-line-number": {
		"prefix": "tm-line-number",
		"body": "\\$TM_LINE_NUMBER",
		"description": "从1开始的行号"
	},
	"tm-filename-base": {
		"prefix": "tm-filename-base",
		"body": "\\$TM_FILENAME_BASE",
		"description": "当前文档的文件名,不带扩展名"
	},
	"tm-filename": {
		"prefix": "tm-filename",
		"body": "\\$TM_FILENAME",
		"description": "当前文档的文件名"
	},
	"tm-directory": {
		"prefix": "tm-directory",
		"body": "\\$TM-DIRECTORY",
		"description": "当前文档的目录"
	},
	"tm-filepath": {
		"prefix": "tm-filepath",
		"body": "\\$TM_FILEPATH",
		"description": "当前文档的完整文件路径"
	},
	"relative-filepath": {
		"prefix": "relative-filepath",
		"body": "\\$RELATIVE-FILEPATH",
		"description": "当前文档的相对(相对于打开的工作区或文件夹)文件路径"
	},
	"clipboard": {
		"prefix": "clipboard",
		"body": "\\$CLIPBOARD",
		"description": "剪贴板的内容"
	},
	"workspace-name": {
		"prefix": "workspace-name",
		"body": "\\$WORKSPACE_NAME",
		"description": "打开的工作区或文件夹的名称"
	},
	"workspace-folder": {
		"prefix": "workspace-folder",
		"body": "\\$WORKSPACE_FOLDER",
		"description": "打开的工作区或文件夹的路径"
	},
	"current-year": {
		"prefix": "current-year",
		"body": "\\$CURRENT_YEAR",
		"description": "今年"
	},
	"current-year-short": {
		"prefix": "current-year-short",
		"body": "\\$CURRENT_YEAR_SHORT",
		"description": "当前年份的最后两位数字"
	},
	"current-month": {
		"prefix": "current-month",
		"body": "\\$CURRENT_MONTH",
		"description": "月份为两位数(例如“02”)"
	},
	"current-month-name": {
		"prefix": "current-month-name",
		"body": "\\$CURRENT_MONTH_NAME",
		"description": "月份的全名(例如“July”)"
	},
	"current-month-name-short": {
		"prefix": "current-month-name-short",
		"body": "\\$CURRENT_MONTH_NAME_SHORT",
		"description": "月份的简称(例如“Jul”)"
	},
	"current-date": {
		"prefix": "current-date",
		"body": "\\$CURRENT_DATE",
		"description": "一个月中的哪一天"
	},
	"current-day-name": {
		"prefix": "current-day-name",
		"body": "\\$CURRENT_DAY_NAME",
		"description": "日期名称(例如“Monday”)"
	},
	"current-day-name-short": {
		"prefix": "current-day-name-short",
		"body": "\\$CURRENT_DAY_NAME_SHORT",
		"description": "一天的简称(例如“Mon”)"
	},
	"current-hour24": {
		"prefix": "current-hour24",
		"body": "\\$CURRENT_HOUR24",
		"description": "小时制的当前小时"
	},
	"current-minute": {
		"prefix": "current-minute",
		"body": "\\$CURRENT_MINUTE",
		"description": "当前分钟"
	},
	"current-second": {
		"prefix": "current-second",
		"body": "\\$CURRENT_SECOND",
		"description": "当前秒"
	},
	"current-seconds-unix": {
		"prefix": "current-seconds-unix",
		"body": "\\$CURRENT_SECONDS_UNIX",
		"description": "自Unix纪元以来的秒数"
	},
	"block-comment-start": {
		"prefix": "block-comment-start",
		"body": "\\$BLOCK_COMMENT_START",
		"description": "块注释的开始,例如java中的/*"
	},
	"block-comment-end": {
		"prefix": "block-comment-end",
		"body": "\\$BLOCK_COMMENT_END",
		"description": "块注释的结束,例如java中的*/"
	},
	"line-comment": {
		"prefix": "line-comment",
		"body": "\\$LINE_COMMENT",
		"description": "行注释,例如java中的//"
	},
	"template": {
		"prefix": "template",
		"body": [
			"\"$1\": {",
			"\t\"prefix\": \"$1\",",
			"\t\"body\": [$2]",
			"},"
		]
	}

现在假设你在学thymeleaf模板框架。可以边学边把知识点写成模板。这样你学完以后你也拥有了自己的智能提示。当然除了模板智能提示,你也可以用Maven的自定义模板。有兴趣可以看官网。和之前一样建议先写模板的模板。
下面就是我主要参考下面文章写的模板,这里分享出来。

html.json

    "strings.": {
        "prefix": "strings.",
        "body": "#strings.${1|toString,isEmpty,arrayIsEmpty,listIsEmpty,setIsEmpty,defaultString,arrayDefaultString,listDefaultString,setDefaultString,contains,containsIgnoreCase,startsWith,endsWith,indexOf,substring,substringAfter,substringBefore,replace,prepend,append,toUpperCase,toLowerCase,arrayJoin,listJoin,setJoin,arraySplit,listSplit,setSplit,trim,length,abbreviate,capitalize,unCapitalize,capitalizeWords,capitalizeWords,escapeXml,escapeJava,escapeJavaScript,unescapeJava,unescapeJavaScript,equals,equalsIgnoreCase,concat,concatReplaceNulls|}(${2:$TM_SELECTED_TEXT})"
    },
    "objects.": {
        "prefix": "objects.",
        "body": "#objects.${1|nullSafe,arrayNullSafe,listNullSafe,setNullSafe|}(${2:$TM_SELECTED_TEXT})"
    },
    "numbers.": {
        "prefix": "numbers.",
        "body": "#numbers.${1|listFormatInteger,arrayFormatInteger,setFormatInteger,formatDecimal,arrayFormatDecimal,listFormatDecimal,setFormatDecimal,formatDecimal,sequence,formatInteger|}(${2:$TM_SELECTED_TEXT})"
    },
    "calendars.": {
        "prefix": "calendars.",
        "body": "#calendars.${1|format,arrayFormat,listFormat,setFormat,formatISO,arrayFormatISO,listFormatISO,setFormatISO,format,arrayFormat,listFormat,setFormat,day,month,monthName,monthNameShort,year,dayOfWeek,dayOfWeekName,dayOfWeekNameShort,hour,minute,second,millisecond,create,createForTimeZone,createNow,createNowForTimeZone,createToday,createTodayForTimeZone|}(${2:$TM_SELECTED_TEXT})"
    },
    "dates.": {
        "prefix": "dates.",
        "body": "#dates.${1|format,arrayFormat,setFormat,formatISO,arrayFormatISO,listFormatISO,setFormatISO,listFormat,setFormat,day,month,monthName,monthNameShort,year,dayOfWeek,dayOfWeekName,dayOfWeekNameShort,hour,minute,second,millisecond,create,createNow,createNowForTimeZone,createToday,createTodayForTimeZone|}(${2:$TM_SELECTED_TEXT})"
    },
    "th:": {
        "prefix": "th:",
        "body": "th:${1|id,style,class,include,replace,each,if,unless,switch,case,object,with,attr,attrprepend,attrappend,value,href,src,text,utext,fragment,remove|}='${2:$TM_SELECTED_TEXT}'"
    },
    "xmlns-th": {
        "prefix": "xmlns-th",
        "body": "xmlns:th=http://www.thymeleaf.org ",
        "description": "thymeleaf"
    },
    "xmlns-sec": {
        "prefix": "xmlns-sec",
        "body": "xmlns:sec=http://www.thymeleaf.org/extras/spring-security ",
        "description": "sec安全验证标签"
    },
    "xmlns-shiro": {
        "prefix": "xmlns-shiro",
        "body": "xmlns:shiro=http://www.pollix.at/thymeleaf/shiro ",
        "description": "访问控制标签"
    },
    "🔗链接": {
        "prefix": "link",
        "body": [
            "@{$TM_SELECTED_TEXT}"
        ],
        "description": "链接🔗"
    },
    "链接🔗": {
        "prefix": "url",
        "body": "@{$TM_SELECTED_TEXT}",
        "description": "链接🔗"
    },
    "#": {
        "prefix": "#",
        "body": [
            "#{$TM_SELECTED_TEXT}"
        ],
        "description": "国际化信息"
    },
    "*": {
        "prefix": "*",
        "body": [
            "*{$TM_SELECTED_TEXT}"
        ],
        "description": "选择"
    },
    "$": {
        "prefix": "$",
        "body": [
            "${$TM_SELECTED_TEXT}"
        ],
        "description": "变量"
    },
  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2021-07-13 17:40:56  更:2021-07-13 17:43:16 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年12日历 -2024/12/22 14:12:29-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码