代码随想录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

相关推荐
qq_3384323714 小时前
VS Code 远程 WSL 中 Claude Code 导致 Java 文件修改被自动撤回的一次排查
vscode·vibe coding·claude code
Mars-xq19 小时前
vscode 开发Android
android·ide·vscode
嵌入式小站21 小时前
STM32 可移植教程 01:VSCode 环境搭建 + 点亮 LED(实战篇)
vscode·stm32·嵌入式硬件
Mars-xq21 小时前
VSCode 开发 Android 时,类、方法无法跳转
android·ide·vscode
Mars-xq21 小时前
VSCode 开发Android 新手必装插件清单
android·ide·vscode
xskukuku1 天前
使用VSCode配置C语言运行环境
c语言·ide·vscode
小王C语言1 天前
vscode智能提示问题、跳转问题
ide·vscode·编辑器
郝亚军2 天前
如何在vscode上运行python程序
ide·vscode·编辑器
Arvin.Angela2 天前
VsCode 安装文档
ide·vscode·编辑器
CAir22 天前
copilot配置deepseek和skills
vscode·copilot·skill·deepseek