11

有谁知道我可以在 Visual Studio 2008 片段中插入当前日期和时间的方法?我想要的是在我的 .snippet 文件的正文中这样的东西......

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

1 回答 1

18

没有可用于片段的 DateTime 函数,但这里有一个将插入当前 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

您可以使用Alt+打开宏浏览F8器并创建一个新模块并将上面的代码粘贴到生成的模块中。

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

于 2009-06-22T20:20:42.827 回答