VS2010:自动将日期和首字母插入单行注释

Buf*_*alo 4 c# automation comments visual-studio-2010

问候朋友,

每当我将单行注释放入我的代码库时,Visual Studio 2010自动插入当前日期和我的名字/首字母的最佳方式(键击次数最少)是什么?这应该支持C#,如果它也适用于我的.aspx页面,它会更好.

谢谢 - 我知道有人在那里有完美的解决方案:).

Ray*_*und 6

创建一个宏并分配一个快捷键.

最简单的方法是转到Tools-> Macros-> Macro Explorer并编辑其中一个样本,我使用Samples-> VSEditor,右键单击那个并编辑.现在您在宏编辑器中现在创建此功能.

Sub NewCommentLinePersonal()
    Dim textSelection As EnvDTE.TextSelection

    textSelection = DTE.ActiveWindow.Selection
    textSelection.NewLine()
    textSelection.Insert(Utilities.LineOrientedCommentStart())
    textSelection.Insert(" " + Date.Now + " - Your Initial ")
End Sub
Run Code Online (Sandbox Code Playgroud)

然后转到Tools->Options->Environment->Keyboard并键入NewCommentLinePersonal文本框"显示包含:的命令",然后选择您的快捷键