VS2019利用Macro函数注释添加姓名和日期

更新时间:2023-05-12 14:13:34 阅读: 评论:0

VS2019利⽤Macro函数注释添加姓名和⽇期1.添加 Macros for Visual Studio 扩展
2. 添加 Macro 脚本
Method Note 中的代码如下():
var date = new Date();
var year = Year();
var month = Month() + 1;
var day = Date();
var hours = Hours();
var minutes = Minutes();
month = month < 10 ? ("0" + month) : ("" + month);
day = day < 10 ? ("0" + day) : ("" + day);
hours = hours < 10 ? ("0" + hours) : ("" + hours);
minutes = minutes < 10 ? ("0" + minutes) : ("" + minutes);
var doc = dte.ActiveDocument;
doc.Selection.Text = "///";
doc.Selection.LineDown();
doc.Selection.EndOfLine();
doc.Selection.NewLine();
doc.Selection.Text = "<remark>";
doc.Selection.NewLine();
doc.Selection.LineUp();
doc.Selection.EndOfLine();
doc.Selection.NewLine();
doc.Selection.Text = "<para/>Author  :  AnDequan";
doc.Selection.NewLine();
doc.Selection.Text = "<para/>Date    :  " + year + "-" + month + "-" + day + " " + hours + ":" + minutes;
3.添加 快捷键 ,本⼈⽤的 Ctrl M,1
4.效果演⽰:
在 Class 或者 函数 上 使⽤快捷键 Ctrl M,1 即可
同理做了⼀个单⾏注释如下图:
# 附录:
MethodNote.js
var day = Date();
var hours = Hours();
var minutes = Minutes();
if (month == 1) month = 13;
if (month == 2) month = 14;
var week = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 + year / 400) % 7 + 1; week = parInt(week);
var xingqi = "";
if (week == 1) { xingqi = "星期⽇"; }
el if (week == 2) { xingqi = "星期⼀"; }
el if (week == 3) { xingqi = "星期⼆"; }
el if (week == 4) { xingqi = "星期三"; }
el if (week == 5) { xingqi = "星期四"; }
el if (week == 6) { xingqi = "星期五"; }
el if (week == 7) { xingqi = "星期六"; }
month = month < 10 ? ("0" + month) : ("" + month);
day = day < 10 ? ("0" + day) : ("" + day);
hours = hours < 10 ? ("0" + hours) : ("" + hours);
minutes = minutes < 10 ? ("0" + minutes) : ("" + minutes);
var time = year + "-" + month + "-" + day + " " + hours + ":" + minutes;
var justDay = year + "-" + month + "-" + day;
var doc = dte.ActiveDocument;
doc.Selection.Text = "///";
doc.Selection.LineDown();
doc.Selection.EndOfLine();
doc.Selection.NewLine();
doc.Selection.Text = "<remark>";
doc.Selection.NewLine();
doc.Selection.LineUp();
doc.Selection.EndOfLine();
doc.Selection.NewLine();
doc.Selection.Text = "<para/>Author  :  An";
doc.Selection.NewLine();
doc.Selection.Text = "<para/>Date    :  " + time + " " + xingqi;
doc.Selection.LineUp();
doc.Selection.LineUp();
doc.Selection.LineUp();
doc.Selection.LineUp();
SingleLineNote.js
var day = Date();
var hours = Hours();
var minutes = Minutes();
if (month == 1) month = 13;
if (month == 2) month = 14;
var week = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 + year / 400) % 7 + 1; week = parInt(week);
var xingqi = "";
if (week == 1) { xingqi = "星期⽇"; }
el if (week == 2) { xingqi = "星期⼀"; }
el if (week == 3) { xingqi = "星期⼆"; }
el if (week == 4) { xingqi = "星期三"; }
el if (week == 5) { xingqi = "星期四"; }
el if (week == 6) { xingqi = "星期五"; }
el if (week == 7) { xingqi = "星期六"; }
month = month < 10 ? ("0" + month) : ("" + month);
day = day < 10 ? ("0" + day) : ("" + day);
hours = hours < 10 ? ("0" + hours) : ("" + hours);
minutes = minutes < 10 ? ("0" + minutes) : ("" + minutes);
var time = year + "-" + month + "-" + day + " " + hours + ":" + minutes;
var justDay = year + "-" + month + "-" + day;
var doc = dte.ActiveDocument;
doc.Selection.Text = "// [  ] An " + time + " " + xingqi + "";
doc.Selection.CharLeft(fal, 24);
doc.Selection.CharLeft();
doc.Selection.Text = "";
doc.Selection.CharLeft();
doc.Selection.Text = "";

本文发布于:2023-05-12 14:13:34,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/600397.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:添加   注释   姓名   函数   脚本   快捷键
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图