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

相关推荐
Hello World . .6 天前
Linux:线程间通信
linux·开发语言·vscode
被制作时长两年半的个人练习生6 天前
claude code for vscode 配置 qwen3.5
ide·vscode·claude code·qwen3.5
圣心6 天前
Visual Studio Code 中的 AI 智能操作
ide·人工智能·vscode
吹牛不交税6 天前
关于vscode左侧资源管理器目录层级疑似异常的问题
ide·vscode·编辑器
嵌入小生0076 天前
线程间通信---嵌入式(Linux)
linux·c语言·vscode·嵌入式·互斥锁·线程间通信·信号量
琛説6 天前
彻底解决 Codex / Copilot 修改中文乱码【含自动化解决方案】
vscode·copilot·codex
学嵌入式的小杨同学6 天前
嵌入式硬件开发入门:PCB 设计核心流程 + 基础元器件实战指南
vscode·后端·嵌入式硬件·架构·vim·智能硬件·pcb工艺
刘恒1234567896 天前
VSCODE
vscode
你怎么知道我是队长7 天前
VsCode插件推荐---Todo Tree
ide·vscode·编辑器
becatjd7 天前
VScode的claude code插件报错command ‘claude-vscode.editor.openLast‘ not found
ide·vscode·编辑器·claude·anthropic·claude code