代码随想录day2

目录

  • [vscode 自定义代码模板](#vscode 自定义代码模板)
  • Reference

vscode 自定义代码模板

  1. select User snippets from Settings on the bottom left corner.

  2. select a certain language

for example: cpp

  1. create your own snippets
    格式如下,防着写
  • 第一行"cpp template",模板的名称
  • "prefix",快捷键,在文件中输入cpp,按下tab就会自动填充"body"里的代码。
  • ${CURRENT_YEAR} 这个是个变量,当年年份
  • $1, $2,$3...是光标的顺序,按TAB键就可以切换为下一个,$0特殊 为光标最后所在地方。
  • "description"代码片段描述,随便写写。
json 复制代码
{
	"cpp template": {
		"prefix": "cpp",
		"body": [
			"/** ",
			" * @Date: ${CURRENT_YEAR} ${CURRENT_MONTH_NAME_SHORT} ${CURRENT_DATE}",
			" * @Time: ${CURRENT_HOUR}:${CURRENT_MINUTE}",
			" * @Author: Chris",
			" * @Desc: ${1:Input the description of this file}",
			"**/"
			"#include <iostream>",
			"",
			"using namespace std;",
			"",
			"int main() {",
			"	$0",
			"	return 0;",
			"}",
		],
		"description": "A cpp file template."
	}	
}
  1. Usage
    输入cpp,然后按下tab

效果如图,光标先跳到desc 这里输入完文件描述,然后按下tab,光标就会跳到主函数里面

Reference

Snippets in Visual Studio Code

相关推荐
guigui_hello6 小时前
VScode的简单使用
c++·ide·vscode·编辑器
MicrosoftReactor16 小时前
技术速递|VS Code Java 8月更新 - 重要 Gradle 更新!用户体验与入门向导增强
java·vscode
tjjingpan16 小时前
vscode c++编译环境配置
c++·ide·vscode
天天向上10241 天前
使用vscode开发uniapp, 摆脱hbuilder
ide·vscode·uni-app
数云界1 天前
使用 VSCode 在 Python 中创建项目环境
ide·vscode·python
m0_608570981 天前
vscode对python进行多卡调试
ide·vscode·python
冲,干,闯1 天前
VScode相关问题与解决
c++·ide·vscode
悟空不是猴子1 天前
VS Code终端命令执行后老是出现 __vsc_prompt_cmd_original: command not found
windows·vscode·prompt·bash
冰淇淋烤布蕾2 天前
git 你要如何打开这个文件
git·vscode·intellij-idea
我命由我123452 天前
1.使用 VSCode 过程中的英语积累 - File 菜单(每一次重点积累 5 个单词)
ide·经验分享·vscode·学习·编辑器·生活·学习方法