Sub header and or synopsis, byline
Download commentCode and unCommentCode
Author: sam AT sam-i-am.com
last modified: February 09, 2001
This package includes two scripts -- one to comment code, the other to uncomment code.
Each works with a selection, and prepends/strips comment characters at the beginning of each line.
Code indentation is preserved.
This greatly speeds development and debugging by allowing whole blocks of code to be rapidly commented and uncommented - with a keystroke or from the toolbar.
Both scripts work by attempting to guess what comment characters (language) is required from the file extension.
E.g .pl, .cgi, .pm (or any file beginning with # - the perl "shebang") will use '#' as the comment character.
Files with extensions .java, .js the comment character is taken to be '//'.
By default '//' is used.
N.B. the scripts do not currently support block characters like /* */. However Homesite will already comment html using SHIFT + CTRL + M.)
The zip file also contains an icon for each (these are very lame but kind of get the message across :)
However in Homesite 4.5+ I would (also) recommend a keyboard mapping for each.
I use CTRL + ALT + M and SHIFT + CTRL + ALT + M for comment/uncomment respectively.
Selecting the following code and hitting your CommentCode button (or assigned keyboard shortcut) ...
this.divObjArr = new Array();
this.imageArr = new Array();
// these correspond to the mouseOver and mouseOut states
this.imgOffObjArr = new Array();
this.imgOnObjArr = new Array();
this.imageName = imageDir;
// this.divObjArr = new Array();
// this.imageArr = new Array();
// // these correspond to the mouseOver and mouseOut states
// this.imgOffObjArr = new Array();
// this.imgOnObjArr = new Array();
// this.imageName = imageDir;
Notice how the previously commented line is commented again. I removed an earlier feature that would have left those lines as-is on the reasoning that when un-commenting the same selection we would rather leave previous comments intact.
Applying unCommentCode would restore the same selection to its exact original state.