插入当前日期时间在Visual Studio代码段 [英] Insert current datetime in Visual Studio Snippet

查看:4132
本文介绍了插入当前日期时间在Visual Studio代码段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道我可以插入当前日期和放大器的方法;一次在Visual Studio 2008的代码片段?我想在我的是.snippet文件...

 <的身体像这样,代码语言=CSHARP > 
<![CDATA [
$ // $的DateTime
//更多代码在这里为我的片段...
< /代码>


解决方案

有可用的片段没有日期时间函数,但这里是将插入当前日期时间的宏:

 子打印日期()
。如果(不IsNothing(DTE.ActiveDocument) )然后
尺寸选择作为TextSelection = DTE.ActiveDocument.Selection
selection.Insert(DateTime.Now.ToString())
端如果
端子

您可以打开你的宏资源管理器<大骨节病>替代 + <大骨节病> F8 并创建新的模块和代码粘贴上面生成的模块内。



然后创建一个新的快捷键并将其绑定到您的宏。


Does anyone know of a way that I can insert the current date & time in a visual studio 2008 snippet? What I want is something like this in the body of my .snippet file...

  <Code Language="csharp">
    <![CDATA[
  // $DateTime$
  // more code here for my snippet...
  </Code>

解决方案

There are no DateTime functions available for snippets but here is a macro that will insert the current DateTime:

Sub PrintDateTime()
    If (Not IsNothing(DTE.ActiveDocument)) Then
        Dim selection As TextSelection = DTE.ActiveDocument.Selection
        selection.Insert(DateTime.Now.ToString())
    End If
End Sub

You can open your macro explorer with Alt + F8 and create a new module and paste the code above inside the module that is generated.

Then create a new keyboard shortcut and bind it to your macro.

这篇关于插入当前日期时间在Visual Studio代码段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆