Create a comment snippet

Hi,

I would like to create a snippet for comments. This is easy for static data but I want to add the sub or function name dynamically so wherever I insert the snippet it should add the name of the function or sub that I'm currently in. Guess it would look something like:



' <Procedure name>
'
' Objective :
'
' Parameters :
'
' Author :
'
' History :

 



And obviously I want the Author and Procedure name tags to be filled automatically.

Is there any way to do this with a snippet Or are there any other tools that would do this for me

Regards,
neiden



Answer this question

Create a comment snippet

  • Eli Robillard

    Hi neiden,

    Thank you for submitting this question.  Unfortunately, we do not currently have support in VB code snippets for the kind of function you would need to produce this behavior.  We have considered the idea, but unfortunately that functionality has not been prioritized enough to make it into a release.

    If you have an opportunity, can you please file a suggestion in MSDN Feedback: http://lab.msdn.microsoft.com/productfeedback/   That is the best way for us to track customer suggestions to consider for future releases.

    In the meantime, it is possible to write a macro to achieve your goal.  That is what DMan1's earlier response was trying to convey.  However, at that point you would not be using snippets.  You would essentially be creating a macro to call whenever you wanted to insert one of these comments.  (Not quite as easy as having a snippet do the work for you... :( )

    Thanks,

    Lisa Feigenbaum
    Visual Basic Program Manager


  • Poida

    The following is a cut from a macro project in VS IDE...it's not exactly what you want but it should give you an idea of what road to travel down!



    Imports EnvDTE

    Imports EnvDTE80

    Imports System.Diagnostics

    Imports System.Windows

    Imports System.Windows.Forms

    Imports System

    Public Module CreateProperty

    Private Sub CreateProperty(ByVal PropertyName As String, ByVal PropertyScope As String, ByVal PropertyType As String)

    DTE.ActiveDocument.Selection.NewLine()

    DTE.ActiveDocument.Selection.Text = "Private m_" & PropertyName & " as " & PropertyType

    DTE.ActiveDocument.Selection.NewLine()

    DTE.ActiveDocument.Selection.Text = PropertyScope & " Property " & PropertyName & "() as " & PropertyType

    DTE.ActiveDocument.Selection.NewLine()

    DTE.ActiveDocument.Selection.Text = "Return m_" & PropertyName

    DTE.ActiveDocument.Selection.LineDown(False, 3)

    DTE.ActiveDocument.Selection.Text = "m_" & PropertyName & " = value"

    DTE.ActiveDocument.Selection.LineDown(False, 3)

    DTE.ActiveDocument.Selection.NewLine()

    End Sub

     

    Sub CreateInteger()

    Dim PropertyName As String = InputBox("Enter Name Of Property")

    Dim PropertyScope As String = "Public"

    Dim PropertyType As String = "Integer"

    CreateProperty(PropertyName, PropertyScope, PropertyType)

    End Sub




     


  • Steve Powell

    Have you looked in the IntelliSense Code Snippets FAQ yet

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=61654&SiteID=1#_Toc109549594



  • Create a comment snippet