XstreamINsanity
XstreamINsanity

Reputation: 4296

How to create standard comment blocks?

At my previous job they used a product called "Whole Tomato" (I think that's what it's called) and it allowed you save custom blocks of code. That way, if you wanted to use it over again, all you'd have to do is start typing what the code block would look like and then it'd give you a drop down option of available blocks. Well, is there anyway, within visual studio itself, to create standard comment templates. That way, if I wanted to put the following as a comment for every function:

/***************************************************************************
Programmer:  John Smith
Date Written:  09/28/2010
Reviewed By:  Jane Doe
Description Of Function:  N/A
Comments:  N/A

Example:
  public void test()
  {
  }
***************************************************************************/

Could I do that without having to save it somewhere and copy and pasting? I'm familiar with the XML that gets provided when typing /// (for C#) or ''' (for VB), but that's not really what we want to do. If it's too much such as creating a custom add-in or installing an already existing addin (unless it's free) then we're not too worried about it. I just thought there might be a way to do this. Thanks for any advice and answers.

Upvotes: 0

Views: 270

Answers (2)

stijn
stijn

Reputation: 35901

the simplest way is to create a macro that inserts those lines at the current cursor position, and assign a shortcut to that macro. Example to get you started (select text to add comment for):

Sub InsertComment()
  Dim selection As EnvDTE.TextSelection = DTE.ActiveDocument.Selection
  Dim curSelectionText = selection.Text
  selection.LineUp()
  selection.Text = "//" + curSelectionText + " [ comment goes here ]"
End Sub

the product was Visual Assist X btw ;P

Upvotes: 2

David
David

Reputation: 34543

If you make the toolbox window visible, you can drag & drop code from the code window into the toolbox. Then whenever you want to use that code again, just drag & drop it back into the code window.

Upvotes: 1

Related Questions