vscode 添加版权信息

   考虑到大工程每个cpp和h文件都要增加版权信息,每次都复制粘贴,有点麻烦,于是就想着怎么省事。通过查找,原来以为koroFileHeader这个插件可以搞定,后来发现它只能提供json格式的文件头部信息,相当于文档注释,它出来的结果是在文件头部添加类似

@xxx 内容

格式的注释,对于版权信息肯定不合适,所以不采用这种方式。

     又调研了以下发现可以使用代码片段来实现,所谓代码片段就是用指定的前缀表示一定量的代码,这段代码还可以添加变量。对于我们来说,我们的这段代码就是固定的,所以这个比较简单。

也就是使用Snippets工具,vscode自带了snipper,通过文件--首选项--用户片段--输入自定义的片段文件的名字,回车得到模板,接下来我们将该模板改动以下即可:

{
 "add Copyright notice": {
	"prefix": [ "header", "stub", "copyright"],
  "body": [
	  "/* ==================================================================",
	  "* Copyright (c) 2020,xxxx.",
	  "* All rights reserved.",
	  "*",
	  "* Redistribution and use in source and binary forms, with or without",
	  "* modification, are permitted provided that the following conditions",
	  "* are met:",
	  "*",
	  "* 1. Redistributions of source code must retain the above copyright",
	  "* notice, this list of conditions and the following disclaimer.",
	  "* 2. Redistributions in binary form must reproduce the above copyright",
	  "* notice, this list of conditions and the following disclaimer in the",
	  "* documentation and/or other materials provided with the",
	  "* distribution.",
	  "* 3. All advertising materials mentioning features or use of this software",
	  "* must display the following acknowledgement:",
	  "* This product includes software developed by the xxx Group. and",
	  "* its contributors.",
	  "* 4. Neither the name of the Group nor the names of its contributors may",
	  "* be used to endorse or promote products derived from this software",
	  "* without specific prior written permission.",
	  "*",
	  "* THIS SOFTWARE IS PROVIDED BY xxx,GROUP AND CONTRIBUTORS",
	  "* ===================================================================",
	  "* Author: xxx XXX.",
	  "*/"
		],
  "description": "Adds copyright..."
 }
}

保存,退出。

接下来使用这些代码片段,上述片段中"prefix": [ "header", "stub", "copyright"],定义了3个选项,在我们的文件中输入这3者中的任意1个,都会提示出可用项:

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值