This is a quick & dirty port of Ian Nowland's extremely useful CommentReflower plugin for Visual Studio 2003 and 2005. You can find the original distribution at the Comment Reflower home page.
This port was first cobbled together by Christoph Nahr in June 2008, with several later revisions. I have no connection whatsoever with Ian Nowland and no experience with Visual Studio add-ins either, but since he hasn’t updated Comment Reflower in years I decided to give it a shot. Since I cannot update the original SourceForge project I’ve put my version up for download at my own website.
Important: If Visual Studio refuses to load the add-in, please read my note on automatic execution blocking when unpacking ZIP archives on Windows!
The binary package for Visual Studio 2008 contains an older version of Comment Reflower that was compiled using VS2008. The only difference from a user perspective is that you need to substitute 2008 for 2010 in the file paths shown in the next section.
Comment Reflower supports XCopy deployment. Simply extract the entire contents of the current binary package,
CommentReflower.zip, to one of the directories that Visual Studio searches for add-ins. You can find the complete list of supported locations under Tools > Options > Environment > Add-in/Macros Security within Visual Studio 2010. See the MSDN page Visual Studio Add-In Security for further details.
As an example, here is a possible location for a user-specific installation. Substitute your Windows user name for <User> to get the actual directory:
You will find the following files in your deployment folder:
The settings file is not part of the distribution package but will be created the first time you use the Settings dialog. If you have a settings file from an older version of Comment Reflower, you can simply copy it to the deployment folder.
I’m not using Visual Studio 2012 myself, but Shane Tolmie has discovered that Comment Reflower works just fine with that version, provided you update the add-in control file with the new version number. To simplify matters, Comment Reflower now ships with three copies of the add-in control file:
Comment Reflower comes preconfigured for use with Visual Studio 2010. To use Comment Reflower with Visual Studio 2012, adjust the deployment path in the previous section as needed, and then simply overwrite CommentReflower.AddIn with CommentReflower.AddIn-2012.
All files required to run the add-in are now expected in the same deployment folder, which must be one of the Visual Studio\AddIns folders listed above. This has the following consequences:
If you’re upgrading from the June 2008 version, you will want to copy your existing settings file to the new location. Substituting your user name for <User> and your Visual Studio version number for <Version>, you can find your old settings file at the following location (on Windows Vista):
The following list shows all projects in the original 2005 distribution and what happened to them in the current source code package,
CommentReflower – The library assembly that connects the add-in to the Visual Studio IDE. Rewritten for Visual Studio 2010 with some changes as described below.
CommentReflowerHelp – The HTML Help 1.3 project that generates the help file. Updated to reflect the new command names and put in the root directory, otherwise unchanged. This project is not attached to the Visual Studio solution and must be built manually. The project folder already contains a prebuilt CHM file, however.
CommentReflowerLib – The library assembly that provides the actual reflowing logic. Unchanged.
CommentReflowerTest – A command-line executable that tests the CommentReflowerLib assembly. Unchanged, except that the command-line window now waits for a keystroke before closing. Check the execution directory in the project properties before attempting to run this project!
CommentReflowerResourceDll – A resource assembly providing a few command icons which are frankly quite ugly. Not included in this distribution; all commands are shown as text only.
CommentReflowerSetup – The setup project that creates the MSI distribution package. Not included in this distribution since I have no experience with the MSI technology and don’t know how to upgrade this project to VS2010 so that it actually runs on someone else’s machine. Ian Nowland’s original ReadMe.rtf file is located in the root directory, however.
The settings file used to reside in LocalUserAppData, then moved to UserAppData in the June 2008 revision, i.e. the “Roaming” version of the same directory; and finally to the AddIns folder in the January 2009 revision.
Some internal names have changed as well. The CommentReflower add-in name is now simply CommentReflower.Connect, with no version suffix such as 2003, 2005, or 2008. Its GUID has changed as well, although it is currently unused. The command names provided by Comment Reflower were shortened and changed to the standard verb form, as follows:
|Align Parameters at Cursor||CommentReflower.Connect.AlignParameters|
|Reflow Comment at Cursor||CommentReflower.Connect.ReflowPoint|
|Reflow All Comments in Selection||CommentReflower.Connect.ReflowSelection|
|Comment Reflower Settings||CommentReflower.Connect.Settings|
Each command has a corresponding entry in the Tools menu, and except for Settings also in the context menu of the code editor window. Moreover, each command can be bound to a keyboard shortcut using the Tools: Options: Keyboard dialog. The AlignParameters command is unavailable by default, and must be enabled explicitly using the “Enable Align Params” button in the Settings dialog.
Note: Comment Reflower does not support block comments with non-empty Block Start & Block End fields but an empty (or whitespace) Line Start field, e.g. traditional C-style block comments without leading asterisks on each line. Apparently the comment matching algorithm cannot detect such a combination. Try using the “Empty Block for Text Files” style instead if you require a style without Line Start characters.
October 2012 – Added AddIn control file for Visual Studio 2012, as advised by Shane Tolmie.
November 2011 – Restored original version of file CommentReflower\AssemblyInfo.cs.
July 2010 – Added note regarding empty Line Start field, as detected by David W Smith.
May 2010 – Corrected description of Visual Studio add-in locations, as advised by Martin Richter.
April 2010 – Recompiled and otherwise updated for Visual Studio 2010.
March 2010 – Fixed AlignParameters command. When the first parameter is preceded by one or more spaces or tabs, parameters on the following lines are now correctly aligned with the start of the first parameter, rather than with the first space character after the opening parenthesis. Bug report and fix were submitted by Arnt Witteveen.
January 2009 – Revised for XCopy deployment to the Visual Studio AddIns folder, as described above.
June 2008 – Original release for Visual Studio 2008.