By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,975 Members | 1,131 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,975 IT Pros & Developers. It's quick & easy.

Automatically Add Comment Header to Source Files

P: n/a
I am looking for a Visual Studio plugin or macro to manage comment
headers in my .cs files (e.g., for copyright and/or open source
license information). I realize that I could edit the template
Class.cs file in %Program Files%\Microsoft Visual Studio 8\Common7\IDE
\ItemTemplates\CSharp\1033\Class.zip; however, this would only work
for classes I create from now on.

I believe there are commercial programs out there that do this (e.g.,
Fast Formatter from http://www.elegancetech.com/FF.aspx) but this is a
bit heavyweight for my needs and, as a student, I'd prefer free/open
source tools if possible.

j

Feb 5 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 4 Feb 2007 21:28:38 -0800, "jonfroehlich" <jo**********@gmail.com>
wrote:
>I am looking for a Visual Studio plugin or macro to manage comment
headers in my .cs files (e.g., for copyright and/or open source
license information). I realize that I could edit the template
Class.cs file in %Program Files%\Microsoft Visual Studio 8\Common7\IDE
\ItemTemplates\CSharp\1033\Class.zip; however, this would only work
for classes I create from now on.

I believe there are commercial programs out there that do this (e.g.,
Fast Formatter from http://www.elegancetech.com/FF.aspx) but this is a
bit heavyweight for my needs and, as a student, I'd prefer free/open
source tools if possible.

j
As a student you lack both money and programming experience. Why not
solve both problems by writing the program you need for yourself? You
might even get your instructor to accept it as a term project or for
extra credit.

rossum

Feb 5 '07 #2

P: n/a
On 5 Feb, 14:07, rossum <rossu...@coldmail.comwrote:
On 4 Feb 2007 21:28:38 -0800, "jonfroehlich" <jonfroehl...@gmail.com>
wrote:
I am looking for a Visual Studio plugin or macro to manage comment
headers in my .cs files (e.g., for copyright and/or open source
license information). I realize that I could edit the template
Class.cs file in %Program Files%\Microsoft Visual Studio 8\Common7\IDE
\ItemTemplates\CSharp\1033\Class.zip; however, this would only work
for classes I create from now on.
I believe there are commercial programs out there that do this (e.g.,
Fast Formatter fromhttp://www.elegancetech.com/FF.aspx) but this is a
bit heavyweight for my needs and, as a student, I'd prefer free/open
source tools if possible.
j

As a student you lack both money and programming experience. Why not
solve both problems by writing the program you need for yourself? You
might even get your instructor to accept it as a term project or for
extra credit.

rossum
It's not a bad idea. MZ-Tools (My favourite add in ever) can add
comments and headers and so forth and is pretty cheap, but In relation
to Rossum's suggestion the web site has lots of resources for creating
your own add ins.

http://www.mztools.com/index.htm

and

http://www.mztools.com/resources_addin_developers.htm

Feb 5 '07 #3

P: n/a
On 4 Feb 2007 21:28:38 -0800, "jonfroehlich" <jo**********@gmail.comwrote:
>I am looking for a Visual Studio plugin or macro to manage comment
headers in my .cs files (e.g., for copyright and/or open source
license information). I realize that I could edit the template
Class.cs file in %Program Files%\Microsoft Visual Studio 8\Common7\IDE
\ItemTemplates\CSharp\1033\Class.zip; however, this would only work
for classes I create from now on.

I believe there are commercial programs out there that do this (e.g.,
Fast Formatter from http://www.elegancetech.com/FF.aspx) but this is a
bit heavyweight for my needs and, as a student, I'd prefer free/open
source tools if possible.

j
Make a new folder under Macros and copy this into it.

'Put a file header at the cursor position
Sub FileHeader()
Dim doc As Document
Dim docName As String

' Get the name of this object from the file name
doc = DTE.ActiveDocument
docName = doc.Name 'get the name of the current document

DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.LineUp()
DTE.ActiveDocument.Selection.Text = "/* *"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text =
"================================================= ============================"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "Copyright " & Date.Today & ", Your
Name"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text =
"================================================= ============================"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "File Name:"
DTE.ActiveDocument.Selection.Indent(5)
DTE.ActiveDocument.Selection.Text = docName
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "Programmer:"
DTE.ActiveDocument.Selection.Indent(4)
DTE.ActiveDocument.Selection.Text = "Tom Childers"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "Creation Date:"
DTE.ActiveDocument.Selection.Indent(3)
DTE.ActiveDocument.Selection.Text = Date.Today
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text =
"================================================= ============================"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "Description:"
DTE.ActiveDocument.Selection.Indent(4)
DTE.ActiveDocument.Selection.Text = "DESCRIPTION"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text =
"================================================= ============================"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "Modification Date:"
DTE.ActiveDocument.Selection.Indent()
DTE.ActiveDocument.Selection.Text = "MODDATE"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text =
"================================================= ============================"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "*/"
End Sub
Good luck with your project,

Otis Mukinfus

http://www.otismukinfus.com
http://www.arltex.com
http://www.tomchilders.com
http://www.n5ge.com
Feb 6 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.