当前位置: 首页 > news >正文

VSCode学习笔记一:添加代码模板

一目了然

  • 1 简述
  • 2 设置模板
  • 3 Global Snippets file示例

1 简述

问:为什么要设置代码模板?
答:编程语言是有个性的,不同语言的演讲风格是不一样的。
旁白:我不懂?!

问:为什么要设置代码模板?
答:同种语言的演讲内容是不一样的,但是演讲稿的框架可以是一样的。
旁白:我懂了?!

问:为什么要设置代码模板?
答:好吧,我承认,每次复制粘贴的操作也是相当费键盘的,我需要快捷的方式在不同格式的语言文件中填充不同的框架内容。
旁白:VSCode说它可以。

2 设置模板

点击VSCode界面左下角的齿轮图标,在弹出界面中点击“User Snippets”选项,如下图所示:

Manage -> User Snippets

此时会在界面顶部弹出选项,供用户选择需要为哪种语言添加模板,如下图所示:

Language Snippets

选择你要添加的模板语言,然后就可以在模板文件中添加自定义的文件模板了,需要注意的是模板文件的格式为“json”格式。

也可以创建一个“Global Snippets file”模板文件,在这个文件中可以为各种语言添加文件模板。

3 Global Snippets file示例

下面的代码展示的是一个“Global Snippets file”示例:

{// Place your global 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": "log",// 	"body": [// 		"console.log('$1');",// 		"$2"// 	],// 	"description": "Log output to console"// }"C function file template": {"prefix": "cfile","body": ["/**"," * CONFIDENTIAL and PROPRIETARY"," *   Copyright (c) XXX Automotive System Co.,LTD. All rights reserved."," *"," * FILE INFORMATION"," *   FILE NAME: ${TM_FILENAME}"," *   AUTHOR(S): XXX"," *"," * BRIEF INFORMATION"," *   function file."," */","","/*---------------------------------------------------------------------------"," *         Header Files"," *---------------------------------------------------------------------------*/","","/*---------------------------------------------------------------------------"," *         Local Defines"," *---------------------------------------------------------------------------*/","","/*---------------------------------------------------------------------------"," *         Local Variables"," *---------------------------------------------------------------------------*/","","/*---------------------------------------------------------------------------"," *         Global Variables"," *---------------------------------------------------------------------------*/","","/*---------------------------------------------------------------------------"," *         Local Functions"," *---------------------------------------------------------------------------*/","/**"," * Abstract:"," *   Function."," *"," * Parameter:"," *   argc: Parameter."," *"," * Return:"," *   None."," */","","/*---------------------------------------------------------------------------"," *         Global Functions"," *---------------------------------------------------------------------------*/","/**"," * Abstract:"," *   Function."," *"," * Parameter:"," *   argc: Parameter."," *"," * Return:"," *   None."," */","",""],"description": "C function file template."},"C header file template": {"prefix": "hfile","body": ["/**"," * CONFIDENTIAL and PROPRIETARY"," *   Copyright (c) XXX Automotive System Co.,LTD. All rights reserved."," *"," * FILE INFORMATION"," *   FILE NAME: ${TM_FILENAME}"," *   AUTHOR(S): XXX"," *"," * BRIEF INFORMATION"," *   header file."," */","","#ifndef _${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H_INCLUDED_","#define _${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H_INCLUDED_","","/*---------------------------------------------------------------------------"," *         Header Files"," *---------------------------------------------------------------------------*/","","/*---------------------------------------------------------------------------"," *         Defines"," *---------------------------------------------------------------------------*/","","/*---------------------------------------------------------------------------"," *         Types"," *---------------------------------------------------------------------------*/","","/*---------------------------------------------------------------------------"," *         Exported Functions"," *---------------------------------------------------------------------------*/","","","#endif  /* End #ifndef _${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H_INCLUDED_ */",""],"description": "C header file template."},"GTest function file template": {"prefix": "gtest","body": ["/**"," * CONFIDENTIAL and PROPRIETARY"," *   Copyright (c) XXX Automotive System Co.,LTD. All rights reserved."," *"," * FILE INFORMATION"," *   FILE NAME: ${TM_FILENAME}"," *   AUTHOR(S): XXX"," *"," * BRIEF INFORMATION"," *   unit test file."," */","","/*---------------------------------------------------------------------------"," *         Header Files"," *---------------------------------------------------------------------------*/","#include <stdio.h>""#include <stdlib.h>""#include <gtest/gtest.h>""/* Include C-format header file. */""extern \"C\" {""    #include \"\"""}","","using namespace std;","/*---------------------------------------------------------------------------"," *         Defines"," *---------------------------------------------------------------------------*/","","/*---------------------------------------------------------------------------"," *         Variables"," *---------------------------------------------------------------------------*/","","/*---------------------------------------------------------------------------"," *         Functions"," *---------------------------------------------------------------------------*/","/**"," * Abstract:"," *   Function."," *"," * Parameter:"," *   argc: Parameter."," *"," * Return:"," *   None."," */",""],"description": "GTest function file template."},"Python file template": {"prefix": "pyfile","body": ["# CONFIDENTIAL and PROPRIETARY","#   Copyright (c) XXX Automotive System Co.,LTD. All rights reserved.","#","# FILE INFORMATION","#   FILE NAME: ${TM_FILENAME}","#   AUTHOR(S): XXX","#","# BRIEF INFORMATION","#   file information.","","# Import modules or packages.","",""],"description": "Python file template."},
}

在上述代码中供定义了四种文件模板:

  • cfile: C语言源码文件模板
  • hfile: C语言头文件模板
  • gtest: GTest源码文件模板
  • pyfile: Python文件模板

当为VSCode添加了上述“Global Snippets file”内容后,在空白文件中就可以通过输入提示词(cfile,hfile,gtest,pyfile)然后点击回车按键填充文件了。

相关文章:

VSCode学习笔记一:添加代码模板

一目了然 1 简述2 设置模板3 Global Snippets file示例 1 简述 问&#xff1a;为什么要设置代码模板&#xff1f; 答&#xff1a;编程语言是有个性的&#xff0c;不同语言的演讲风格是不一样的。 旁白&#xff1a;我不懂&#xff1f;&#xff01; 问&#xff1a;为什么要设置…...

Linux下修改jar包中的配置文件application.conf

文件位置 jar包文件工程目录 打包后解压jar包目录 提取和上传 jar tf XXX.jar # 获取包内文件 application.conf是jar包的配置文件&#xff0c;如果修改需要 提取文件 jar xf my-app.jar application.conf 修改后上传文件 jar uf my-app.jar application.conf...

【python绘图—colorbar操作学习】

文章目录 Colorbar的作用Colorbar的操作截取cmap拼接cmap双刻度列colorbar 引用 Colorbar的作用 Colorbar&#xff08;颜色条&#xff09;在绘图中的作用非常重要&#xff0c;它主要用于以下几个方面&#xff1a; 表示数据范围&#xff1a; Colorbar可以显示图中的颜色映射范围…...

Python+Appium自动化测试-编写自动化脚本

之前已经讲述怎样手动使用appium-desktop启动测试机上的app&#xff0c;但我们实际跑自动化脚本的过程中&#xff0c;是需要用脚本调用appium启动app的&#xff0c;接下来就尝试写Python脚本启动app并登陆app。环境为Windows10 Python3.7 appium1.18.0 Android手机 今日头条…...

AMEYA360|ROHM罗姆首次推出硅电容器BTD1RVFL系列

全球知名半导体制造商ROHM(总部位于日本京都市)新开发出在智能手机和可穿戴设备等领域应用日益广泛的硅电容器。利用ROHM多年来积累的硅半导体加工技术&#xff0c;新产品同时实现了更小的尺寸和更高的性能。 随着智能手机等应用的功能增加和性能提升&#xff0c;业界对于支持更…...

Linux发散小知识

linux/unix哲学&#xff1a;KISS Keep It Simple and Stuid。 "提供一套机制&#xff0c;而不是策略"&#xff0c;“万般皆文本&#xff0c;四处用脚本” unix的数据流追求简单化、通用性、可视性、设备无关&#xff0c;二进制肯定无法做到这些&#xff0c;因此文本…...

GTS 中testPeakPssOfAllApps fail 详解

0. 前言 GTS 在测试 case armeabi-v7a GtsMemoryHostTestCases 的时候出现下面异常&#xff0c;本文总结一下。 com.google.android.memory.gts.AllAppsMemoryHostTest#testPeakPssOfAllApps 1. error log 09-14 10:16:34 I/TestFailureListener: FailureListener.testFaile…...

linux查看远程仓库的分支

在 Linux 终端中&#xff0c;您可以使用 git 命令来查看远程仓库的分支。git 是版本控制系统&#xff0c;用于管理代码的版本和协作开发。以下是查看远程仓库分支的方法&#xff1a; 查看所有远程分支&#xff1a; git ls-remote <remote_repository_url> 这个命令会显示…...

【Linux常用命令】

编程不良人 Linux 笔记 一、防火墙相关 1、查看防火墙状态 systemctl status flrewalld2、如果防火墙是开启状态的&#xff0c;需要关闭 systemctl stop firewalld3、永久行关闭操作&#xff08;禁止开机自启动&#xff09; 因为防火默认是开启状态的&#xff0c;如果只是手…...

QString类与整型,浮点数互转

本文介绍QString类与整型&#xff0c;浮点数之间的相互转换。 1.QString类转整型 QString类转整型&#xff08;包含2进制&#xff0c;8进制&#xff0c;16进制&#xff09;&#xff0c;可以使用QString的toInt()函数。 QString str("1234"); bool bOK false; int…...

基于STM32F407ZET6的环境温湿度监控系统(粤嵌GEC-M4)

注意使用事项&#xff1a; 开发板如下 由于外部晶振是8M&#xff0c;需要修改setup和stm32f4头文件的晶振值。 操作如下&#xff1a; system_stm32f4xx.c的254行 #define PLL_M 8stm32f4xx.h的127行 #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the Ex…...

2023年五一杯数学建模A题无人机定点投放问题求解全过程论文及程序

2023年五一杯数学建模 A题 无人机定点投放问题 原题再现&#xff1a; 随着科学技术的不断发展&#xff0c;无人机在许多领域都有着广泛的应用。对于空中执行定点投放任务的无人机&#xff0c;其投放精度不仅依赖于无人机的操作技术&#xff0c;而且还与无人机执行任务时所处状…...

Redis 7 第九讲 微服务集成Redis 应用篇

Jedis 理论 Jedis是redis的java版本的客户端实现&#xff0c;使用Jedis提供的Java API对Redis进行操作&#xff0c;是Redis官方推崇的方式&#xff1b;并且&#xff0c;使用Jedis提供的对Redis的支持也最为灵活、全面&#xff1b;不足之处&#xff0c;就是编码复杂度较高。 …...

c++day7

仿照vector手动实现自己的myVector&#xff0c;最主要实现二倍扩容功能 #include <iostream>using namespace std; template <typename T> class Myvector { private:T *start;//起始指针T *end;//数组末尾指针T *last;//数组有效长度的尾指针 public://定义无参构…...

C++学习概述

1.c 为啥需要头文件 如果您刚开始使用 C&#xff0c;您可能想知道为什么C需要 #include 头文件&#xff0c;以及为什么一个程序要拥有多个 .cpp 文件。 原因很简单&#xff1a; a) 减少编译时间 随着程序的增长&#xff0c;您的代码也会增长&#xff0c;如果所有内容都在一个…...

关系型数据库和非关系型数据库

关系型数据库和非关系型数据库 关系型数据库非关系型数据库 非关系型数据库和关系型数据库是两种不同类型的数据库管理系统&#xff0c;它们用于存储和管理数据&#xff0c;但在数据组织和处理方式上有一些重要的区别。 关系型数据库 1.结构化数据存储&#xff1a;关系型数据库…...

基于SSM的快餐店点餐服务系统设计与实现

末尾获取源码 开发语言&#xff1a;Java Java开发工具&#xff1a;JDK1.8 后端框架&#xff1a;SSM 前端&#xff1a;采用JSP技术开发 数据库&#xff1a;MySQL5.7和Navicat管理工具结合 服务器&#xff1a;Tomcat8.5 开发软件&#xff1a;IDEA / Eclipse 是否Maven项目&#x…...

使用vcpkg配置CGAL+visual studio 2022

先安装vcpkg C:\dev> git clone https://github.com/microsoft/vcpkg C:\dev> cd vcpkg C:\dev\vcpkg> .\bootstrap-vcpkg.bat 运行后&#xff0c;先执行 C:\dev\vcpkg> .\vcpkg.exe install yasm-tool:x86-windows 这是因为gmp库中有个bug&#xff0c;只能这样…...

【Spring面试】三、Bean的配置、线程安全、自动装配

文章目录 Q1、什么是Spring Bean&#xff1f;和对象有什么区别Q2、配置Bean有哪几种方式&#xff1f;Q3、Spring支持的Bean有哪几种作用域&#xff1f;Q4、单例Bean的优势是什么&#xff1f;Q5、Spring的Bean是线程安全的吗&#xff1f;Q6、Spring如何处理线程并发问题&#xf…...

flink连接kafka报:org.apache.kafka.common.errors.TimeoutException

测试flink1.12.7 连接kafka&#xff1a; package org.test.flink;import org.apache.flink.api.common.serialization.SimpleStringSchema; import org.apache.flink.streaming.api.datastream.DataStream; import org.apache.flink.streaming.api.environment.StreamExecutio…...

未来机器人的大脑:如何用神经网络模拟器实现更智能的决策?

编辑&#xff1a;陈萍萍的公主一点人工一点智能 未来机器人的大脑&#xff1a;如何用神经网络模拟器实现更智能的决策&#xff1f;RWM通过双自回归机制有效解决了复合误差、部分可观测性和随机动力学等关键挑战&#xff0c;在不依赖领域特定归纳偏见的条件下实现了卓越的预测准…...

Xshell远程连接Kali(默认 | 私钥)Note版

前言:xshell远程连接&#xff0c;私钥连接和常规默认连接 任务一 开启ssh服务 service ssh status //查看ssh服务状态 service ssh start //开启ssh服务 update-rc.d ssh enable //开启自启动ssh服务 任务二 修改配置文件 vi /etc/ssh/ssh_config //第一…...

k8s从入门到放弃之Ingress七层负载

k8s从入门到放弃之Ingress七层负载 在Kubernetes&#xff08;简称K8s&#xff09;中&#xff0c;Ingress是一个API对象&#xff0c;它允许你定义如何从集群外部访问集群内部的服务。Ingress可以提供负载均衡、SSL终结和基于名称的虚拟主机等功能。通过Ingress&#xff0c;你可…...

python/java环境配置

环境变量放一起 python&#xff1a; 1.首先下载Python Python下载地址&#xff1a;Download Python | Python.org downloads ---windows -- 64 2.安装Python 下面两个&#xff0c;然后自定义&#xff0c;全选 可以把前4个选上 3.环境配置 1&#xff09;搜高级系统设置 2…...

新能源汽车智慧充电桩管理方案:新能源充电桩散热问题及消防安全监管方案

随着新能源汽车的快速普及&#xff0c;充电桩作为核心配套设施&#xff0c;其安全性与可靠性备受关注。然而&#xff0c;在高温、高负荷运行环境下&#xff0c;充电桩的散热问题与消防安全隐患日益凸显&#xff0c;成为制约行业发展的关键瓶颈。 如何通过智慧化管理手段优化散…...

ArcGIS Pro制作水平横向图例+多级标注

今天介绍下载ArcGIS Pro中如何设置水平横向图例。 之前我们介绍了ArcGIS的横向图例制作&#xff1a;ArcGIS横向、多列图例、顺序重排、符号居中、批量更改图例符号等等&#xff08;ArcGIS出图图例8大技巧&#xff09;&#xff0c;那这次我们看看ArcGIS Pro如何更加快捷的操作。…...

群晖NAS如何在虚拟机创建飞牛NAS

套件中心下载安装Virtual Machine Manager 创建虚拟机 配置虚拟机 飞牛官网下载 https://iso.liveupdate.fnnas.com/x86_64/trim/fnos-0.9.2-863.iso 群晖NAS如何在虚拟机创建飞牛NAS - 个人信息分享...

python爬虫——气象数据爬取

一、导入库与全局配置 python 运行 import json import datetime import time import requests from sqlalchemy import create_engine import csv import pandas as pd作用&#xff1a; 引入数据解析、网络请求、时间处理、数据库操作等所需库。requests&#xff1a;发送 …...

Java求职者面试指南:Spring、Spring Boot、Spring MVC与MyBatis技术解析

Java求职者面试指南&#xff1a;Spring、Spring Boot、Spring MVC与MyBatis技术解析 一、第一轮基础概念问题 1. Spring框架的核心容器是什么&#xff1f;它的作用是什么&#xff1f; Spring框架的核心容器是IoC&#xff08;控制反转&#xff09;容器。它的主要作用是管理对…...

前端调试HTTP状态码

1xx&#xff08;信息类状态码&#xff09; 这类状态码表示临时响应&#xff0c;需要客户端继续处理请求。 100 Continue 服务器已收到请求的初始部分&#xff0c;客户端应继续发送剩余部分。 2xx&#xff08;成功类状态码&#xff09; 表示请求已成功被服务器接收、理解并处…...